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

changeset 1780
6e5076af4660
parent 1760
33d1937af1a3
child 1811
349160289ba2
equal deleted inserted replaced
1779:97a9b4b3e63a 1780:6e5076af4660
851 Symbol sym, 851 Symbol sym,
852 Env<AttrContext> env, 852 Env<AttrContext> env,
853 final List<JCExpression> argtrees, 853 final List<JCExpression> argtrees,
854 List<Type> argtypes, 854 List<Type> argtypes,
855 boolean useVarargs, 855 boolean useVarargs,
856 boolean unchecked) { 856 boolean unchecked,
857 InferenceContext inferenceContext) {
857 // System.out.println("call : " + env.tree); 858 // System.out.println("call : " + env.tree);
858 // System.out.println("method : " + owntype); 859 // System.out.println("method : " + owntype);
859 // System.out.println("actuals: " + argtypes); 860 // System.out.println("actuals: " + argtypes);
860 List<Type> formals = owntype.getParameterTypes(); 861 List<Type> formals = owntype.getParameterTypes();
861 Type last = useVarargs ? formals.last() : null; 862 Type last = useVarargs ? formals.last() : null;
915 warnUnchecked(env.tree.pos(), 916 warnUnchecked(env.tree.pos(),
916 "unchecked.generic.array.creation", 917 "unchecked.generic.array.creation",
917 argtype); 918 argtype);
918 } 919 }
919 if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) { 920 if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) {
920 TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype)); 921 setVarargsElement(env, types.elemtype(argtype), inferenceContext);
921 } 922 }
922 } 923 }
923 PolyKind pkind = (sym.type.hasTag(FORALL) && 924 PolyKind pkind = (sym.type.hasTag(FORALL) &&
924 sym.type.getReturnType().containsAny(((ForAll)sym.type).tvars)) ? 925 sym.type.getReturnType().containsAny(((ForAll)sym.type).tvars)) ?
925 PolyKind.POLY : PolyKind.STANDALONE; 926 PolyKind.POLY : PolyKind.STANDALONE;
926 TreeInfo.setPolyKind(env.tree, pkind); 927 TreeInfo.setPolyKind(env.tree, pkind);
927 return owntype; 928 return owntype;
928 } 929 }
929 //where 930 //where
931 private void setVarargsElement(final Env<AttrContext> env, final Type elemtype, InferenceContext inferenceContext) {
932 if (inferenceContext.free(elemtype)) {
933 inferenceContext.addFreeTypeListener(List.of(elemtype), new FreeTypeListener() {
934 public void typesInferred(InferenceContext inferenceContext) {
935 setVarargsElement(env, inferenceContext.asInstType(elemtype), inferenceContext);
936 }
937 });
938 }
939 TreeInfo.setVarargsElement(env.tree, elemtype);
940 }
941
930 private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) { 942 private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
931 if (types.isConvertible(actual, formal, warn)) 943 if (types.isConvertible(actual, formal, warn))
932 return; 944 return;
933 945
934 if (formal.isCompound() 946 if (formal.isCompound()

mercurial