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

changeset 1897
866c87c01285
parent 1896
44e27378f523
child 1898
a204cf7aab7e
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 17 14:04:01 2013 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 17 14:09:46 2013 +0100
     1.3 @@ -149,7 +149,7 @@
     1.4          inferenceException.clear();
     1.5          try {
     1.6              DeferredAttr.DeferredAttrContext deferredAttrContext =
     1.7 -                    resolveContext.deferredAttrContext(msym, inferenceContext, resultInfo, warn);
     1.8 +                        resolveContext.deferredAttrContext(msym, inferenceContext, resultInfo, warn);
     1.9  
    1.10              resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext,
    1.11                      argtypes, mt.getParameterTypes(), warn);
    1.12 @@ -225,32 +225,32 @@
    1.13                      inferenceContext.restvars(), mt.getReturnType(), to);
    1.14          }
    1.15      }
    1.16 -    //where
    1.17 -        private Type returnConstraintTarget(Type from, Type to) {
    1.18 -            if (from.hasTag(VOID)) {
    1.19 -                return syms.voidType;
    1.20 -            } else if (to.hasTag(NONE)) {
    1.21 -                return from.isPrimitive() ? from : syms.objectType;
    1.22 -            } else if (from.hasTag(UNDETVAR) && to.isPrimitive()) {
    1.23 -                if (!allowGraphInference) {
    1.24 -                    //if legacy, just return boxed type
    1.25 -                    return types.boxedClass(to).type;
    1.26 +
    1.27 +    Type returnConstraintTarget(Type from, Type to) {
    1.28 +        if (from.hasTag(VOID)) {
    1.29 +            return syms.voidType;
    1.30 +        } else if (to.hasTag(NONE)) {
    1.31 +            return from.isPrimitive() ? from : syms.objectType;
    1.32 +        } else if (from.hasTag(UNDETVAR) && to.isPrimitive()) {
    1.33 +            if (!allowGraphInference) {
    1.34 +                //if legacy, just return boxed type
    1.35 +                return types.boxedClass(to).type;
    1.36 +            }
    1.37 +            //if graph inference we need to skip conflicting boxed bounds...
    1.38 +            UndetVar uv = (UndetVar)from;
    1.39 +            for (Type t : uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) {
    1.40 +                Type boundAsPrimitive = types.unboxedType(t);
    1.41 +                if (boundAsPrimitive == null) continue;
    1.42 +                if (types.isConvertible(boundAsPrimitive, to)) {
    1.43 +                    //effectively skip return-type constraint generation (compatibility)
    1.44 +                    return syms.objectType;
    1.45                  }
    1.46 -                //if graph inference we need to skip conflicting boxed bounds...
    1.47 -                UndetVar uv = (UndetVar)from;
    1.48 -                for (Type t : uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) {
    1.49 -                    Type boundAsPrimitive = types.unboxedType(t);
    1.50 -                    if (boundAsPrimitive == null) continue;
    1.51 -                    if (types.isConvertible(boundAsPrimitive, to)) {
    1.52 -                        //effectively skip return-type constraint generation (compatibility)
    1.53 -                        return syms.objectType;
    1.54 -                    }
    1.55 -                }
    1.56 -                return types.boxedClass(to).type;
    1.57 -            } else {
    1.58 -                return to;
    1.59              }
    1.60 +            return types.boxedClass(to).type;
    1.61 +        } else {
    1.62 +            return to;
    1.63          }
    1.64 +    }
    1.65  
    1.66      /**
    1.67        * Infer cyclic inference variables as described in 15.12.2.8.
    1.68 @@ -1337,9 +1337,6 @@
    1.69          /** list of inference vars in this context */
    1.70          List<Type> inferencevars;
    1.71  
    1.72 -        /** backed up inference variables */
    1.73 -        List<Type> saved_undet;
    1.74 -
    1.75          java.util.Map<FreeTypeListener, List<Type>> freeTypeListeners =
    1.76                  new java.util.HashMap<FreeTypeListener, List<Type>>();
    1.77  

mercurial