use of com.sun.tools.javac.code.Symbol.ClassSymbol in project ceylon-compiler by ceylon.
the class Attr method attribDiamond.
Type attribDiamond(Env<AttrContext> env, JCNewClass tree, Type clazztype, Pair<Scope, Scope> mapping, List<Type> argtypes, List<Type> typeargtypes) {
if (clazztype.isErroneous() || clazztype.isInterface() || mapping == erroneousMapping) {
//mapping, return the (possibly erroneous) type unchanged
return clazztype;
}
//dup attribution environment and augment the set of inference variables
Env<AttrContext> localEnv = env.dup(tree);
localEnv.info.tvars = clazztype.tsym.type.getTypeArguments();
//if the type of the instance creation expression is a class type
//apply method resolution inference (JLS 15.12.2.7). The return type
//of the resolved constructor will be a partially instantiated type
((ClassSymbol) clazztype.tsym).members_field = mapping.snd;
Symbol constructor;
try {
constructor = rs.resolveDiamond(tree.pos(), localEnv, clazztype.tsym.type, argtypes, typeargtypes);
} finally {
((ClassSymbol) clazztype.tsym).members_field = mapping.fst;
}
if (constructor.kind == MTH) {
ClassType ct = new ClassType(clazztype.getEnclosingType(), clazztype.tsym.type.getTypeArguments(), clazztype.tsym);
clazztype = checkMethod(ct, constructor, localEnv, tree.args, argtypes, typeargtypes, localEnv.info.varArgs).getReturnType();
} else {
clazztype = syms.errType;
}
if (clazztype.tag == FORALL && !pt.isErroneous()) {
//bounds (JLS 15.12.2.8).
try {
clazztype = infer.instantiateExpr((ForAll) clazztype, pt.tag == NONE ? syms.objectType : pt, Warner.noWarnings);
} catch (Infer.InferenceException ex) {
//an error occurred while inferring uninstantiated type-variables
log.error(tree.clazz.pos(), "cant.apply.diamond.1", diags.fragment("diamond", clazztype.tsym), ex.diagnostic);
}
}
return chk.checkClassType(tree.clazz.pos(), clazztype, true);
}
use of com.sun.tools.javac.code.Symbol.ClassSymbol in project ceylon-compiler by ceylon.
the class Attr method checkEnumInitializer.
/**
* Check for illegal references to static members of enum. In
* an enum type, constructors and initializers may not
* reference its static members unless they are constant.
*
* @param tree The tree making up the variable reference.
* @param env The current environment.
* @param v The variable's symbol.
* @jls section 8.9 Enums
*/
private void checkEnumInitializer(JCTree tree, Env<AttrContext> env, VarSymbol v) {
// is declared to the right of e."
if (isStaticEnumField(v)) {
ClassSymbol enclClass = env.info.scope.owner.enclClass();
if (enclClass == null || enclClass.owner == null)
return;
// reference is OK.
if (v.owner != enclClass && !types.isSubtype(enclClass.type, v.owner.type))
return;
// the reference is OK.
if (!Resolve.isInitializer(env))
return;
log.error(tree.pos(), "illegal.enum.static.ref");
}
}
use of com.sun.tools.javac.code.Symbol.ClassSymbol in project ceylon-compiler by ceylon.
the class ConstructorDocImpl method name.
/**
* Get the name.
*
* @return the name of the member qualified by class (but not package)
*/
public String name() {
ClassSymbol c = sym.enclClass();
String n = c.name.toString();
for (c = c.owner.enclClass(); c != null; c = c.owner.enclClass()) {
n = c.name.toString() + "." + n;
}
return n;
}
use of com.sun.tools.javac.code.Symbol.ClassSymbol in project ceylon-compiler by ceylon.
the class TypesImpl method getDeclaredType.
/**
* {@inheritDoc}
*/
public DeclaredType getDeclaredType(DeclaredType containing, TypeDeclaration decl, TypeMirror... typeArgs) {
if (containing == null)
return getDeclaredType(decl, typeArgs);
ClassSymbol sym = ((TypeDeclarationImpl) decl).sym;
Type outer = ((TypeMirrorImpl) containing).type;
if (outer.tsym != sym.owner.enclClass())
throw new IllegalArgumentException(containing.toString());
if (!outer.isParameterized())
return getDeclaredType(decl, typeArgs);
return getDeclaredType(outer, sym, typeArgs);
}
Aggregations