src/share/classes/com/sun/tools/javac/comp/MemberEnter.java

changeset 1374
c002fdee76fd
parent 1358
fc123bdeddb8
child 1384
bf54daa9dcd8
equal deleted inserted replaced
1373:4a1c57a1c410 1374:c002fdee76fd
40 import com.sun.tools.javac.tree.JCTree.*; 40 import com.sun.tools.javac.tree.JCTree.*;
41 41
42 import static com.sun.tools.javac.code.Flags.*; 42 import static com.sun.tools.javac.code.Flags.*;
43 import static com.sun.tools.javac.code.Flags.ANNOTATION; 43 import static com.sun.tools.javac.code.Flags.ANNOTATION;
44 import static com.sun.tools.javac.code.Kinds.*; 44 import static com.sun.tools.javac.code.Kinds.*;
45 import static com.sun.tools.javac.code.TypeTags.*; 45 import static com.sun.tools.javac.code.TypeTag.CLASS;
46 import static com.sun.tools.javac.code.TypeTag.ERROR;
47 import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
46 import static com.sun.tools.javac.tree.JCTree.Tag.*; 48 import static com.sun.tools.javac.tree.JCTree.Tag.*;
47 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; 49 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
48 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 50 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
49 51
50 /** This is the second phase of Enter, in which classes are completed 52 /** This is the second phase of Enter, in which classes are completed
368 370
369 // Attribute thrown exceptions. 371 // Attribute thrown exceptions.
370 ListBuffer<Type> thrownbuf = new ListBuffer<Type>(); 372 ListBuffer<Type> thrownbuf = new ListBuffer<Type>();
371 for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail) { 373 for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail) {
372 Type exc = attr.attribType(l.head, env); 374 Type exc = attr.attribType(l.head, env);
373 if (exc.tag != TYPEVAR) 375 if (!exc.hasTag(TYPEVAR))
374 exc = chk.checkClassType(l.head.pos(), exc); 376 exc = chk.checkClassType(l.head.pos(), exc);
375 thrownbuf.append(exc); 377 thrownbuf.append(exc);
376 } 378 }
377 Type mtype = new MethodType(argbuf.toList(), 379 Type mtype = new MethodType(argbuf.toList(),
378 restype, 380 restype,
919 interfaceTrees = 921 interfaceTrees =
920 interfaceTrees.prepend(make.Type(syms.serializableType)); 922 interfaceTrees.prepend(make.Type(syms.serializableType));
921 } 923 }
922 for (JCExpression iface : interfaceTrees) { 924 for (JCExpression iface : interfaceTrees) {
923 Type i = attr.attribBase(iface, baseEnv, false, true, true); 925 Type i = attr.attribBase(iface, baseEnv, false, true, true);
924 if (i.tag == CLASS) { 926 if (i.hasTag(CLASS)) {
925 interfaces.append(i); 927 interfaces.append(i);
926 if (all_interfaces != null) all_interfaces.append(i); 928 if (all_interfaces != null) all_interfaces.append(i);
927 chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet); 929 chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet);
928 } else { 930 } else {
929 if (all_interfaces == null) 931 if (all_interfaces == null)
1004 if ((c.flags_field & INTERFACE) == 0) { 1006 if ((c.flags_field & INTERFACE) == 0) {
1005 VarSymbol thisSym = 1007 VarSymbol thisSym =
1006 new VarSymbol(FINAL | HASINIT, names._this, c.type, c); 1008 new VarSymbol(FINAL | HASINIT, names._this, c.type, c);
1007 thisSym.pos = Position.FIRSTPOS; 1009 thisSym.pos = Position.FIRSTPOS;
1008 env.info.scope.enter(thisSym); 1010 env.info.scope.enter(thisSym);
1009 if (ct.supertype_field.tag == CLASS) { 1011 if (ct.supertype_field.hasTag(CLASS)) {
1010 VarSymbol superSym = 1012 VarSymbol superSym =
1011 new VarSymbol(FINAL | HASINIT, names._super, 1013 new VarSymbol(FINAL | HASINIT, names._super,
1012 ct.supertype_field, c); 1014 ct.supertype_field, c);
1013 superSym.pos = Position.FIRSTPOS; 1015 superSym.pos = Position.FIRSTPOS;
1014 env.info.scope.enter(superSym); 1016 env.info.scope.enter(superSym);
1092 List.<JCExpression>of(make.Type(c.type))); 1094 List.<JCExpression>of(make.Type(c.type)));
1093 return result; 1095 return result;
1094 } 1096 }
1095 1097
1096 Type modelMissingTypes(Type t, final JCExpression tree, final boolean interfaceExpected) { 1098 Type modelMissingTypes(Type t, final JCExpression tree, final boolean interfaceExpected) {
1097 if (t.tag != ERROR) 1099 if (!t.hasTag(ERROR))
1098 return t; 1100 return t;
1099 1101
1100 return new ErrorType(((ErrorType) t).getOriginalType(), t.tsym) { 1102 return new ErrorType(((ErrorType) t).getOriginalType(), t.tsym) {
1101 private Type modelType; 1103 private Type modelType;
1102 1104
1137 result = syms.errType; 1139 result = syms.errType;
1138 } 1140 }
1139 1141
1140 @Override 1142 @Override
1141 public void visitIdent(JCIdent tree) { 1143 public void visitIdent(JCIdent tree) {
1142 if (tree.type.tag != ERROR) { 1144 if (!tree.type.hasTag(ERROR)) {
1143 result = tree.type; 1145 result = tree.type;
1144 } else { 1146 } else {
1145 result = synthesizeClass(tree.name, syms.unnamedPackage).type; 1147 result = synthesizeClass(tree.name, syms.unnamedPackage).type;
1146 } 1148 }
1147 } 1149 }
1148 1150
1149 @Override 1151 @Override
1150 public void visitSelect(JCFieldAccess tree) { 1152 public void visitSelect(JCFieldAccess tree) {
1151 if (tree.type.tag != ERROR) { 1153 if (!tree.type.hasTag(ERROR)) {
1152 result = tree.type; 1154 result = tree.type;
1153 } else { 1155 } else {
1154 Type selectedType; 1156 Type selectedType;
1155 boolean prev = interfaceExpected; 1157 boolean prev = interfaceExpected;
1156 try { 1158 try {
1164 } 1166 }
1165 } 1167 }
1166 1168
1167 @Override 1169 @Override
1168 public void visitTypeApply(JCTypeApply tree) { 1170 public void visitTypeApply(JCTypeApply tree) {
1169 if (tree.type.tag != ERROR) { 1171 if (!tree.type.hasTag(ERROR)) {
1170 result = tree.type; 1172 result = tree.type;
1171 } else { 1173 } else {
1172 ClassType clazzType = (ClassType) visit(tree.clazz); 1174 ClassType clazzType = (ClassType) visit(tree.clazz);
1173 if (synthesizedSymbols.contains(clazzType.tsym)) 1175 if (synthesizedSymbols.contains(clazzType.tsym))
1174 synthesizeTyparams((ClassSymbol) clazzType.tsym, tree.arguments.size()); 1176 synthesizeTyparams((ClassSymbol) clazzType.tsym, tree.arguments.size());

mercurial