changeset 66:921d71c53d7f

meth-edrfix: tweaks
author jrose
date Thu, 12 Aug 2010 19:31:56 -0700
parents 32f7d51f44ee
children 0e98cb257be0
files meth-edrfix.patch
diffstat 1 files changed, 21 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/meth-edrfix.patch	Thu Aug 12 17:44:35 2010 -0700
+++ b/meth-edrfix.patch	Thu Aug 12 19:31:56 2010 -0700
@@ -56,7 +56,7 @@
                  chk.checkRefTypes(tree.typeargs, typeargtypes);
              }
  
-@@ -1949,12 +1949,50 @@
+@@ -1949,12 +1949,48 @@
          Type clazztype = attribType(tree.clazz, env);
          chk.validate(tree.clazz, env);
          Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly);
@@ -75,7 +75,6 @@
 +        if (targetType.isPrimitive() && expr.getTag() == JCTree.TYPECAST) {
 +            enclosingCast = (JCTypeCast)expr;
 +            if (types.boxedClass(targetType) == enclosingCast.type.tsym) {
-+                System.out.println("*** found prim cast "+expr);
 +                expr = enclosingCast.expr;
 +                // If the expr in turn is a MH.invoke expression,
 +                // we will change (int)(Integer)MH.invoke(...) to (int)MH.invoke(...),
@@ -100,7 +99,6 @@
 +                }
 +            }
 +        }
-+        if (enclosingCast != null && expr == enclosingCast.expr)  System.out.println("*** but failed to match"+expr);
 +        return transformedExpr;
 +    }
 +
@@ -141,7 +139,7 @@
          if (useVarargs && (m.flags() & VARARGS) == 0) return null;
          Type mt = types.memberType(site, m);
  
-@@ -578,13 +582,16 @@
+@@ -578,13 +582,15 @@
          if (sym.kind == ERR) return bestSoFar;
          if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
          assert sym.kind < AMBIGUOUS;
@@ -153,14 +151,13 @@
                  return bestSoFar;
              // Supply an exactly-typed implicit method instead.
 -            sym = findPolymorphicSignatureInstance(env, sym.owner.type, sym.name, (MethodSymbol) sym, argtypes, typeargtypes);
-+            Type restype = syms.objectType;
-+            if (allowTransitionalJSR292)  restype = resultTypeParameter(env, typeargtypes);
++            Type restype = initialPolymorphicSignatureResultType(env, typeargtypes);
 +            sym = findPolymorphicSignatureInstance(sym.owner.type, sym.name, (MethodSymbol) sym, restype, argtypes);
 +            assert null != instantiate(env, site, sym, argtypes, typeargtypes, false, false, Warner.noWarnings);
          }
          try {
              if (rawInstantiate(env, site, sym, argtypes, typeargtypes,
-@@ -757,12 +764,14 @@
+@@ -757,12 +763,13 @@
                        boolean useVarargs,
                        boolean operator) {
          Symbol bestSoFar = methodNotFound;
@@ -171,14 +168,13 @@
              !(useVarargs | allowBoxing | operator)) {
              // supply an exactly-typed implicit method in java.dyn.InvokeDynamic
 -            bestSoFar = findPolymorphicSignatureInstance(env, site, name, null, argtypes, typeargtypes);
-+            Type restype = syms.objectType;
-+            if (allowTransitionalJSR292)  restype = resultTypeParameter(env, typeargtypes);
++            Type restype = initialPolymorphicSignatureResultType(env, typeargtypes);
 +            bestSoFar = findPolymorphicSignatureInstance(site, name, null, restype, argtypes);
 +            assert null != instantiate(env, site, bestSoFar, argtypes, typeargtypes, false, false, Warner.noWarnings);
          }
          return findMethod(env,
                            site,
-@@ -908,43 +917,35 @@
+@@ -908,43 +915,35 @@
      /** Find or create an implicit method of exactly the given type (after erasure).
       *  Searches in a side table, not the main scope of the site.
       *  This emulates the lookup process required by JSR 292 in JVM.
@@ -233,7 +229,7 @@
              exType = List.of(syms.throwableType);
              flags = PUBLIC | STATIC;
          }
-@@ -972,7 +973,7 @@
+@@ -972,7 +971,7 @@
          }
          assert argumentsAcceptable(argtypes, types.memberType(site, m).getParameterTypes(),
                                     false, false, Warner.noWarnings);
@@ -242,7 +238,7 @@
          return m;
      }
      //where
-@@ -989,6 +990,26 @@
+@@ -989,6 +988,29 @@
              return argType;
          }
  
@@ -255,21 +251,24 @@
 +        return ((sym.flags() & (POLYMORPHIC_SIGNATURE | HYPOTHETICAL)) == (POLYMORPHIC_SIGNATURE | HYPOTHETICAL));
 +    }
 +
-+    /** Decode <T> in foo.<T>invoke(bar), for JSR 292 EDR only. */
-+    Type resultTypeParameter(Env<AttrContext> env, List<Type> typeargtypes) {
-+        assert allowTransitionalJSR292;
-+        if (typeargtypes.isEmpty()) {
-+            return syms.objectType;
-+        } else {
++    /** Compute a provisional return type for a polymorphic signature call.
++     *  This is just Object.  It might be retroactively changed by Attr.pushTargetType.
++     *  Decode <T> in foo.<T>invoke(bar), for JSR 292 EDR only.
++     */
++    Type initialPolymorphicSignatureResultType(Env<AttrContext> env, List<Type> typeargtypes) {
++        if (!typeargtypes.isEmpty()) {
 +            log.warning(env.tree.pos, "type.parameter.on.polymorphic.signature");
-+            return typeargtypes.head;
++            if (allowTransitionalJSR292) {
++                return typeargtypes.head;
++            }
 +        }
++        return syms.objectType;
 +    }
 +
      /** Load toplevel or member class with given fully qualified name and
       *  verify that it is accessible.
       *  @param env       The current environment.
-@@ -1367,6 +1388,14 @@
+@@ -1367,6 +1389,14 @@
              methodResolutionCache.put(steps.head, sym);
              steps = steps.tail;
          }
@@ -278,13 +277,13 @@
 +            (site == syms.invokeDynamicType ||
 +             site == syms.methodHandleType && name == names.invoke)) {
 +            // lookup failed; supply an exactly-typed implicit method
-+            sym = findPolymorphicSignatureInstance(site, name, null, resultTypeParameter(env, typeargtypes), argtypes);
++            sym = findPolymorphicSignatureInstance(site, name, null, initialPolymorphicSignatureResultType(env, typeargtypes), argtypes);
 +            env.info.varArgs = false;
 +        }
          if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error
              MethodResolutionPhase errPhase =
                      firstErroneousResolutionPhase();
-@@ -1374,6 +1403,10 @@
+@@ -1374,6 +1404,10 @@
                      pos, site, name, true, argtypes, typeargtypes);
              env.info.varArgs = errPhase.isVarargsRequired;
          }