/** Build an instance of a Type. */ public Type getType(Type baseType, boolean isArray, List<Type> typeParams) { boolean isGeneric = typeParams != null && !typeParams.isEmpty(); if (!isArray && !isGeneric) { // Simple type. return baseType; } else if (isArray && !isGeneric) { // Array type, not generic. ClassSymbol arraySymbol = getSymtab().arrayClass; return new ArrayType(baseType, arraySymbol); } else if (!isArray && isGeneric) { // Generic type, not array. com.sun.tools.javac.util.List<Type> typeParamsCopy = com.sun.tools.javac.util.List.from(typeParams); return new ClassType(Type.noType, typeParamsCopy, baseType.tsym); } else { throw new IllegalArgumentException("Unsupported arguments to getType"); } }
if (!type.asElement().isEnum()) {
@Override public String visitClassType(Type.ClassType t, Void unused) { StringBuilder sb = new StringBuilder(); if (state == null || fix == null) { sb.append(t.tsym.getSimpleName()); } else { sb.append(qualifyType(state, fix, t.tsym)); } if (t.getTypeArguments().nonEmpty()) { sb.append('<'); sb.append( t.getTypeArguments().stream() .map(a -> a.accept(this, null)) .collect(joining(", "))); sb.append(">"); } return sb.toString(); }
if (t.isCompound()) { if (!visit(supertype(t), s)) return false; } else if (s.isRaw()) { return true; } else if (t.isRaw()) { if (!isUnbounded(s)) warnStack.head.warnUnchecked();
if (t.isCompound()) { if (!visit(supertype(t), s)) return false; } else if (s.isRaw()) { return true; } else if (t.isRaw()) { if (!isUnbounded(s)) warnStack.head.warnUnchecked();
if (cls.isRaw() || !cls.isParameterized()) return cls; ClassType G = (ClassType)cls.asElement().asType(); List<Type> A = G.getTypeArguments(); List<Type> T = cls.getTypeArguments(); List<Type> S = freshTypeVariables(T); return new ClassType(cls.getEnclosingType(), S, cls.tsym); else return t;
if (cls.isRaw() || !cls.isParameterized()) return cls; ClassType G = (ClassType)cls.asElement().asType(); List<Type> A = G.getTypeArguments(); List<Type> T = cls.getTypeArguments(); List<Type> S = freshTypeVariables(T); return new ClassType(cls.getEnclosingType(), S, cls.tsym); else return t;
if (!type.asElement().isEnum()) {
return t; ClassType cls = (ClassType)t; if (cls.isRaw() || !cls.isParameterized()) return cls; ClassType G = (ClassType)cls.asElement().asType(); List<Type> A = G.getTypeArguments(); List<Type> T = cls.getTypeArguments(); List<Type> S = freshTypeVariables(T); return new ClassType(cls.getEnclosingType(), S, cls.tsym); else return t;
return t; ClassType cls = (ClassType)t; if (cls.isRaw() || !cls.isParameterized()) return cls; ClassType G = (ClassType)cls.asElement().asType(); List<Type> A = G.getTypeArguments(); List<Type> T = cls.getTypeArguments(); List<Type> S = freshTypeVariables(T); return new ClassType(cls.getEnclosingType(), S, cls.tsym); else return t;
String baseActivityPath = "com.ne1c.rainbowmvp.base.BaseActivity"; if (!((Type.ClassType) baseActivity).asElement().toString().equals(baseActivityPath)) { messager.printMessage(Diagnostic.Kind.ERROR, "Can be annotated only classes that inherit com.ne1c.rainbowmvp.base.BaseActivity");
} else { ClassType classType = (ClassType) value; return Collections.singleton(classType.toString());
@Override public Type visitClassType(ClassType t, Symbol sym) { Symbol owner = sym.owner; long flags = sym.flags(); if (((flags & STATIC) == 0) && owner.type.isParameterized()) { Type base = asOuterSuper(t, owner); //if t is an intersection type T = CT & I1 & I2 ... & In //its supertypes CT, I1, ... In might contain wildcards //so we need to go through capture conversion base = t.isCompound() ? capture(base) : base; if (base != null) { List<Type> ownerParams = owner.type.allparams(); List<Type> baseParams = base.allparams(); if (ownerParams.nonEmpty()) { if (baseParams.isEmpty()) { // then base is a raw type return erasure(sym.type); } else { return subst(sym.type, ownerParams, baseParams); } } } } return sym.type; }
@Override public Boolean visitClassType(ClassType t, Type s) { if (t == s) return true; if (s.isPartial()) return visit(s, t); if (s.isSuperBound() && !s.isExtendsBound()) return visit(t, wildUpperBound(s)) && visit(t, wildLowerBound(s)); if (t.isCompound() && s.isCompound()) { if (!visit(supertype(t), supertype(s))) return false; HashSet<UniqueType> set = new HashSet<UniqueType>(); for (Type x : interfaces(t)) set.add(new UniqueType(x.unannotatedType(), Types.this)); for (Type x : interfaces(s)) { if (!set.remove(new UniqueType(x.unannotatedType(), Types.this))) return false; } return (set.isEmpty()); } return t.tsym == s.tsym && visit(t.getEnclosingType(), s.getEnclosingType()) && containsTypes(t.getTypeArguments(), s.getTypeArguments()); }