src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
changeset 50250 04f9bb270ab8
parent 49876 ac916fea6ec7
child 50287 64c880300d9b
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu May 24 14:35:32 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu May 24 11:13:42 2018 +0100
@@ -2648,6 +2648,7 @@
                 } else if (allowMethodHandles) {
                     MethodSymbol msym = (MethodSymbol)sym;
                     if ((msym.flags() & SIGNATURE_POLYMORPHIC) != 0) {
+                        env.info.pendingResolutionPhase = BASIC;
                         return findPolymorphicSignatureInstance(env, sym, argtypes);
                     }
                 }
@@ -2668,6 +2669,11 @@
                                             List<Type> argtypes) {
         Type mtype = infer.instantiatePolymorphicSignatureInstance(env,
                 (MethodSymbol)spMethod, currentResolutionContext, argtypes);
+        return findPolymorphicSignatureInstance(spMethod, mtype);
+    }
+
+    Symbol findPolymorphicSignatureInstance(final Symbol spMethod,
+                                            Type mtype) {
         for (Symbol sym : polymorphicSignatureScope.getSymbolsByName(spMethod.name)) {
             // Check that there is already a method symbol for the method
             // type and owner
@@ -2935,6 +2941,7 @@
                                   Name name,
                                   List<Type> argtypes,
                                   List<Type> typeargtypes,
+                                  Type descriptor,
                                   MethodCheck methodCheck,
                                   InferenceContext inferenceContext,
                                   ReferenceChooser referenceChooser) {
@@ -2972,6 +2979,15 @@
                 unboundEnv.info.pendingResolutionPhase :
                 boundEnv.info.pendingResolutionPhase;
 
+        if (!res.fst.kind.isResolutionError()) {
+            //handle sigpoly method references
+            MethodSymbol msym = (MethodSymbol)res.fst;
+            if ((msym.flags() & SIGNATURE_POLYMORPHIC) != 0) {
+                env.info.pendingResolutionPhase = BASIC;
+                res = new Pair<>(findPolymorphicSignatureInstance(msym, descriptor), res.snd);
+            }
+        }
+
         return res;
     }