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

changeset 1510
7873d37f5b37
parent 1497
7aa2025bbb7b
child 1513
cf84b07a82db
equal deleted inserted replaced
1509:1985e35e97b2 1510:7873d37f5b37
34 import com.sun.tools.javac.tree.*; 34 import com.sun.tools.javac.tree.*;
35 import com.sun.tools.javac.util.*; 35 import com.sun.tools.javac.util.*;
36 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 36 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
37 import com.sun.tools.javac.util.List; 37 import com.sun.tools.javac.util.List;
38 38
39 import com.sun.tools.javac.tree.JCTree.*;
40 import com.sun.tools.javac.code.Lint; 39 import com.sun.tools.javac.code.Lint;
41 import com.sun.tools.javac.code.Lint.LintCategory; 40 import com.sun.tools.javac.code.Lint.LintCategory;
42 import com.sun.tools.javac.code.Type.*; 41 import com.sun.tools.javac.code.Type.*;
43 import com.sun.tools.javac.code.Symbol.*; 42 import com.sun.tools.javac.code.Symbol.*;
44 import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext; 43 import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext;
45 import com.sun.tools.javac.comp.Infer.InferenceContext; 44 import com.sun.tools.javac.comp.Infer.InferenceContext;
46 import com.sun.tools.javac.comp.Infer.InferenceContext.FreeTypeListener; 45 import com.sun.tools.javac.comp.Infer.InferenceContext.FreeTypeListener;
46 import com.sun.tools.javac.tree.JCTree.*;
47 import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*;
47 48
48 import static com.sun.tools.javac.code.Flags.*; 49 import static com.sun.tools.javac.code.Flags.*;
49 import static com.sun.tools.javac.code.Flags.ANNOTATION; 50 import static com.sun.tools.javac.code.Flags.ANNOTATION;
50 import static com.sun.tools.javac.code.Flags.SYNCHRONIZED; 51 import static com.sun.tools.javac.code.Flags.SYNCHRONIZED;
51 import static com.sun.tools.javac.code.Kinds.*; 52 import static com.sun.tools.javac.code.Kinds.*;
898 types.erasure(owntype.getReturnType()), 899 types.erasure(owntype.getReturnType()),
899 types.erasure(owntype.getThrownTypes()), 900 types.erasure(owntype.getThrownTypes()),
900 syms.methodClass); 901 syms.methodClass);
901 } 902 }
902 if (useVarargs) { 903 if (useVarargs) {
903 JCTree tree = env.tree;
904 Type argtype = owntype.getParameterTypes().last(); 904 Type argtype = owntype.getParameterTypes().last();
905 if (!types.isReifiable(argtype) && 905 if (!types.isReifiable(argtype) &&
906 (!allowSimplifiedVarargs || 906 (!allowSimplifiedVarargs ||
907 sym.attribute(syms.trustMeType.tsym) == null || 907 sym.attribute(syms.trustMeType.tsym) == null ||
908 !isTrustMeAllowedOnMethod(sym))) { 908 !isTrustMeAllowedOnMethod(sym))) {
909 warnUnchecked(env.tree.pos(), 909 warnUnchecked(env.tree.pos(),
910 "unchecked.generic.array.creation", 910 "unchecked.generic.array.creation",
911 argtype); 911 argtype);
912 } 912 }
913 if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) { 913 if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) {
914 Type elemtype = types.elemtype(argtype); 914 TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype));
915 switch (tree.getTag()) {
916 case APPLY:
917 ((JCMethodInvocation) tree).varargsElement = elemtype;
918 break;
919 case NEWCLASS:
920 ((JCNewClass) tree).varargsElement = elemtype;
921 break;
922 case REFERENCE:
923 ((JCMemberReference) tree).varargsElement = elemtype;
924 break;
925 default:
926 throw new AssertionError(""+tree);
927 }
928 } 915 }
929 } 916 }
917 PolyKind pkind = (sym.type.hasTag(FORALL) &&
918 sym.type.getReturnType().containsAny(((ForAll)sym.type).tvars)) ?
919 PolyKind.POLY : PolyKind.STANDALONE;
920 TreeInfo.setPolyKind(env.tree, pkind);
930 return owntype; 921 return owntype;
931 } 922 }
932 //where 923 //where
933 private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) { 924 private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
934 if (types.isConvertible(actual, formal, warn)) 925 if (types.isConvertible(actual, formal, warn))

mercurial