1050 JCBlock body = tree.body; |
1050 JCBlock body = tree.body; |
1051 if (body.stats.isEmpty() || |
1051 if (body.stats.isEmpty() || |
1052 !TreeInfo.isSelfCall(body.stats.head)) { |
1052 !TreeInfo.isSelfCall(body.stats.head)) { |
1053 body.stats = body.stats. |
1053 body.stats = body.stats. |
1054 prepend(typeEnter.SuperCall(make.at(body.pos), |
1054 prepend(typeEnter.SuperCall(make.at(body.pos), |
1055 List.<Type>nil(), |
1055 List.nil(), |
1056 List.<JCVariableDecl>nil(), |
1056 List.nil(), |
1057 false)); |
1057 false)); |
1058 } else if ((env.enclClass.sym.flags() & ENUM) != 0 && |
1058 } else if ((env.enclClass.sym.flags() & ENUM) != 0 && |
1059 (tree.mods.flags & GENERATEDCONSTR) == 0 && |
1059 (tree.mods.flags & GENERATEDCONSTR) == 0 && |
1060 TreeInfo.isSuperCall(body.stats.head)) { |
1060 TreeInfo.isSuperCall(body.stats.head)) { |
1061 // enum constructors are not allowed to call super |
1061 // enum constructors are not allowed to call super |
1451 try { |
1451 try { |
1452 close = rs.resolveQualifiedMethod(pos, |
1452 close = rs.resolveQualifiedMethod(pos, |
1453 env, |
1453 env, |
1454 types.skipTypeVars(resource, false), |
1454 types.skipTypeVars(resource, false), |
1455 names.close, |
1455 names.close, |
1456 List.<Type>nil(), |
1456 List.nil(), |
1457 List.<Type>nil()); |
1457 List.nil()); |
1458 } |
1458 } |
1459 finally { |
1459 finally { |
1460 log.popDiagnosticHandler(discardHandler); |
1460 log.popDiagnosticHandler(discardHandler); |
1461 } |
1461 } |
1462 if (close.kind == MTH && |
1462 if (close.kind == MTH && |
1913 msym.owner == syms.objectType.tsym && |
1913 msym.owner == syms.objectType.tsym && |
1914 methodName == names.getClass && |
1914 methodName == names.getClass && |
1915 argtypes.isEmpty()) { |
1915 argtypes.isEmpty()) { |
1916 // as a special case, x.getClass() has type Class<? extends |X|> |
1916 // as a special case, x.getClass() has type Class<? extends |X|> |
1917 return new ClassType(restype.getEnclosingType(), |
1917 return new ClassType(restype.getEnclosingType(), |
1918 List.<Type>of(new WildcardType(types.erasure(qualifierType), |
1918 List.of(new WildcardType(types.erasure(qualifierType), |
1919 BoundKind.EXTENDS, |
1919 BoundKind.EXTENDS, |
1920 syms.boundClass)), |
1920 syms.boundClass)), |
1921 restype.tsym, |
1921 restype.tsym, |
1922 restype.getMetadata()); |
1922 restype.getMetadata()); |
1923 } else if (msym != null && |
1923 } else if (msym != null && |
1951 } |
1951 } |
1952 |
1952 |
1953 /** Obtain a method type with given argument types. |
1953 /** Obtain a method type with given argument types. |
1954 */ |
1954 */ |
1955 Type newMethodTemplate(Type restype, List<Type> argtypes, List<Type> typeargtypes) { |
1955 Type newMethodTemplate(Type restype, List<Type> argtypes, List<Type> typeargtypes) { |
1956 MethodType mt = new MethodType(argtypes, restype, List.<Type>nil(), syms.methodClass); |
1956 MethodType mt = new MethodType(argtypes, restype, List.nil(), syms.methodClass); |
1957 return (typeargtypes == null) ? mt : (Type)new ForAll(typeargtypes, mt); |
1957 return (typeargtypes == null) ? mt : (Type)new ForAll(typeargtypes, mt); |
1958 } |
1958 } |
1959 |
1959 |
1960 public void visitNewClass(final JCNewClass tree) { |
1960 public void visitNewClass(final JCNewClass tree) { |
1961 Type owntype = types.createErrorType(tree.type); |
1961 Type owntype = types.createErrorType(tree.type); |
2633 argtypes.append(syms.errType); |
2633 argtypes.append(syms.errType); |
2634 } |
2634 } |
2635 return new MethodType(argtypes, Type.recoveryType, |
2635 return new MethodType(argtypes, Type.recoveryType, |
2636 List.of(syms.throwableType), syms.methodClass); |
2636 List.of(syms.throwableType), syms.methodClass); |
2637 case REFERENCE: |
2637 case REFERENCE: |
2638 return new MethodType(List.<Type>nil(), Type.recoveryType, |
2638 return new MethodType(List.nil(), Type.recoveryType, |
2639 List.of(syms.throwableType), syms.methodClass); |
2639 List.of(syms.throwableType), syms.methodClass); |
2640 default: |
2640 default: |
2641 Assert.error("Cannot get here!"); |
2641 Assert.error("Cannot get here!"); |
2642 } |
2642 } |
2643 return null; |
2643 return null; |
2795 /* if the field is static then we need to create a fake clinit |
2795 /* if the field is static then we need to create a fake clinit |
2796 * method, this method can later be reused by LTM. |
2796 * method, this method can later be reused by LTM. |
2797 */ |
2797 */ |
2798 MethodSymbol clinit = clinits.get(enclClass); |
2798 MethodSymbol clinit = clinits.get(enclClass); |
2799 if (clinit == null) { |
2799 if (clinit == null) { |
2800 Type clinitType = new MethodType(List.<Type>nil(), |
2800 Type clinitType = new MethodType(List.nil(), |
2801 syms.voidType, List.<Type>nil(), syms.methodClass); |
2801 syms.voidType, List.nil(), syms.methodClass); |
2802 clinit = new MethodSymbol(STATIC | SYNTHETIC | PRIVATE, |
2802 clinit = new MethodSymbol(STATIC | SYNTHETIC | PRIVATE, |
2803 names.clinit, clinitType, enclClass); |
2803 names.clinit, clinitType, enclClass); |
2804 clinit.params = List.<VarSymbol>nil(); |
2804 clinit.params = List.nil(); |
2805 clinits.put(enclClass, clinit); |
2805 clinits.put(enclClass, clinit); |
2806 } |
2806 } |
2807 newScopeOwner = clinit; |
2807 newScopeOwner = clinit; |
2808 } |
2808 } |
2809 lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared(newScopeOwner))); |
2809 lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared(newScopeOwner))); |
3714 } |
3714 } |
3715 if (normOuter == null) // perhaps from an import |
3715 if (normOuter == null) // perhaps from an import |
3716 normOuter = types.erasure(ownOuter); |
3716 normOuter = types.erasure(ownOuter); |
3717 if (normOuter != ownOuter) |
3717 if (normOuter != ownOuter) |
3718 owntype = new ClassType( |
3718 owntype = new ClassType( |
3719 normOuter, List.<Type>nil(), owntype.tsym, |
3719 normOuter, List.nil(), owntype.tsym, |
3720 owntype.getMetadata()); |
3720 owntype.getMetadata()); |
3721 } |
3721 } |
3722 } |
3722 } |
3723 break; |
3723 break; |
3724 case VAR: |
3724 case VAR: |
4215 extending = null; |
4215 extending = null; |
4216 implementing = bounds; |
4216 implementing = bounds; |
4217 } |
4217 } |
4218 JCClassDecl cd = make.at(tree).ClassDef( |
4218 JCClassDecl cd = make.at(tree).ClassDef( |
4219 make.Modifiers(PUBLIC | ABSTRACT), |
4219 make.Modifiers(PUBLIC | ABSTRACT), |
4220 names.empty, List.<JCTypeParameter>nil(), |
4220 names.empty, List.nil(), |
4221 extending, implementing, List.<JCTree>nil()); |
4221 extending, implementing, List.nil()); |
4222 |
4222 |
4223 ClassSymbol c = (ClassSymbol)owntype.tsym; |
4223 ClassSymbol c = (ClassSymbol)owntype.tsym; |
4224 Assert.check((c.flags() & COMPOUND) != 0); |
4224 Assert.check((c.flags() & COMPOUND) != 0); |
4225 cd.sym = c; |
4225 cd.sym = c; |
4226 c.sourcefile = env.toplevel.sourcefile; |
4226 c.sourcefile = env.toplevel.sourcefile; |
4893 if (md != null && md.restype.hasTag(TYPEIDENT)) { |
4893 if (md != null && md.restype.hasTag(TYPEIDENT)) { |
4894 JCPrimitiveTypeTree prim = (JCPrimitiveTypeTree)md.restype; |
4894 JCPrimitiveTypeTree prim = (JCPrimitiveTypeTree)md.restype; |
4895 if (prim.typetag == VOID) |
4895 if (prim.typetag == VOID) |
4896 restype = syms.voidType; |
4896 restype = syms.voidType; |
4897 } |
4897 } |
4898 return new MethodType(List.<Type>nil(), restype, |
4898 return new MethodType(List.nil(), restype, |
4899 List.<Type>nil(), syms.methodClass); |
4899 List.nil(), syms.methodClass); |
4900 } |
4900 } |
4901 private Type dummyMethodType() { |
4901 private Type dummyMethodType() { |
4902 return dummyMethodType(null); |
4902 return dummyMethodType(null); |
4903 } |
4903 } |
4904 |
4904 |