changeset 2248:0184ece97062

8016177: structural most specific and stuckness 8016178: Order of unsticking functional expressions Remove dead code in most specific check
author mcimadamore
date Thu, 08 Aug 2013 16:41:21 +0100
parents 91c60b02c849
children 654796cd8e47
files src/share/classes/com/sun/tools/javac/comp/Resolve.java
diffstat 1 files changed, 15 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Aug 08 14:30:47 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Aug 08 16:41:21 2013 +0100
@@ -645,7 +645,7 @@
          * Retrieve the method check object that will be used during a
          * most specific check.
          */
-        MethodCheck mostSpecificCheck(Symbol other, List<Type> actuals, boolean strict);
+        MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict);
     }
 
     /**
@@ -691,7 +691,7 @@
             //do nothing - method always applicable regardless of actuals
         }
 
-        public MethodCheck mostSpecificCheck(Symbol other, List<Type> actuals, boolean strict) {
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
             return this;
         }
     };
@@ -766,7 +766,7 @@
             throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
         }
 
-        public MethodCheck mostSpecificCheck(Symbol other, List<Type> actuals, boolean strict) {
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
             return nilMethodCheck;
         }
     }
@@ -862,8 +862,8 @@
         }
 
         @Override
-        public MethodCheck mostSpecificCheck(Symbol other, List<Type> actuals, boolean strict) {
-            return new MostSpecificCheck(other, strict, actuals);
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return new MostSpecificCheck(strict, actuals);
         }
     };
 
@@ -909,8 +909,8 @@
         }
 
         @Override
-        public MethodCheck mostSpecificCheck(Symbol other, List<Type> actuals, boolean strict) {
-            return new MostSpecificCheck(other, strict, actuals);
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return new MostSpecificCheck(strict, actuals);
         }
     };
 
@@ -1006,11 +1006,9 @@
     class MostSpecificCheck implements MethodCheck {
 
         boolean strict;
-        List<Type> actuals;
-        Symbol other;
-
-        MostSpecificCheck(Symbol other, boolean strict, List<Type> actuals) {
-            this.other = other;
+        List<Type> actuals;        Symbol other;
+
+        MostSpecificCheck(boolean strict, List<Type> actuals) {
             this.strict = strict;
             this.actuals = actuals;
         }
@@ -1061,32 +1059,14 @@
                     switch (actual.getTag()) {
                         case DEFERRED:
                             DeferredType dt = (DeferredType) actual;
-                            DeferredType.SpeculativeCache.Entry e1 = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase);
-                            DeferredType.SpeculativeCache.Entry e2 = dt.speculativeCache.get(other, deferredAttrContext.phase);
-                            return (e1 == null || e2 == null ||
-                                    e1.speculativeTree == deferredAttr.stuckTree ||
-                                    e2.speculativeTree == deferredAttr.stuckTree) ?
-                                            false :
-                                            mostSpecific(e2.resultInfo.pt, patchPt(e1), e1.speculativeTree, warn);
+                            DeferredType.SpeculativeCache.Entry e = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase);
+                            return (e == null || e.speculativeTree == deferredAttr.stuckTree)
+                                    ? false : mostSpecific(found, req, e.speculativeTree, warn);
                         default:
                             return standaloneMostSpecific(found, req, actual, warn);
                     }
                 }
             }
-            
-            /**
-             * We need to fixup inference variables in the speculative cache and
-             * replace them the inference variables bring used by the most specific check.
-             */
-            Type patchPt(DeferredType.SpeculativeCache.Entry e) {
-                List<Type> inferenceVarsFrom =
-                        e.resultInfo.checkContext.inferenceContext().inferencevars;
-                List<Type> inferenceVarsTo =
-                        deferredAttrContext.inferenceContext.inferencevars;
-                return types.subst(e.resultInfo.pt,
-                        inferenceVarsFrom.at(inferenceVarsTo.length()), //original method vars are in front
-                        inferenceVarsTo);
-            }
 
             private boolean mostSpecific(Type t, Type s, JCTree tree, Warner warn) {
                 MostSpecificChecker msc = new MostSpecificChecker(t, s, warn);
@@ -1222,7 +1202,7 @@
             }
         }
 
-        public MethodCheck mostSpecificCheck(Symbol other, List<Type> actuals, boolean strict) {
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
             Assert.error("Cannot get here!");
             return null;
         }
@@ -1547,7 +1527,7 @@
             currentResolutionContext = new MethodResolutionContext();
             currentResolutionContext.step = prevResolutionContext.step;
             currentResolutionContext.methodCheck =
-                    prevResolutionContext.methodCheck.mostSpecificCheck(m1, actuals, !allowBoxing);
+                    prevResolutionContext.methodCheck.mostSpecificCheck(actuals, !allowBoxing);
             Type mst = instantiate(env, site, m2, null,
                     adjustArgs(types.lowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null,
                     allowBoxing, useVarargs, noteWarner);