Update jdt.core from origin BETA_JAVA8 with
57e8dd41219d846363c918d62edb5007994c5c79 upto
ac2334c5e86fc350c298c6647ae4cbd01cc6fb31 (today's HEAD of BETA_JAVA8!!)
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
index 4bd6b2e..3fd93b2 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
@@ -266,6 +266,31 @@
 		});
 }
 
+// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=420525#c7
+public void testBug420525a() {
+	runNegativeTest(
+		new String[] {
+			"Main.java",
+			"interface I<T> {\n" + 
+			"    T bold(T t);\n" + 
+			"}\n" + 
+			"\n" + 
+			"class Main {  \n" + 
+			"    public String foo(String x) { return \"<b>\" + x + \"</b>\"; }\n" + 
+			"    String bar() {\n" + 
+			"        I<? extends String> i = this::foo;\n" + 
+			"        return i.bold(\"1\");\n" + 
+			"    }  \n" + 
+			"}\n"
+		},
+		"----------\n" + 
+		"1. ERROR in Main.java (at line 9)\n" + 
+		"	return i.bold(\"1\");\n" + 
+		"	         ^^^^\n" + 
+		"The method bold(capture#1-of ? extends String) in the type I<capture#1-of ? extends String> is not applicable for the arguments (String)\n" + 
+		"----------\n");
+}
+
 public void testBug424415() {
 	runConformTest(
 		new String[] {
@@ -292,6 +317,31 @@
 		});
 }
 
+public void testBug424631() {
+	runConformTest(
+		new String[] {
+			"X.java",
+			"import java.util.ArrayList;\n" + 
+			"import java.util.Collection;\n" + 
+			"\n" + 
+			"interface Functional<T> {\n" + 
+			"   T apply();\n" + 
+			"}\n" + 
+			"\n" + 
+			"class X {\n" + 
+			"    void foo(Collection<String> o) { }\n" + 
+			"\n" + 
+			"	<Q extends Collection<?>> Q goo(Functional<Q> s) {\n" + 
+			"		return null;\n" + 
+			"	} \n" + 
+			"\n" + 
+			"    void test() { \n" + 
+			"        foo(goo(ArrayList<String>::new));\n" + 
+			"    }\n" + 
+			"}\n"
+		});
+}
+
 public void _testBug424403() {
 	runConformTest(
 		new String[] {
@@ -363,4 +413,28 @@
 			"}\n"
 		});
 }
+
+public void testBug424637() {
+	runNegativeTest(
+		new String[] {
+			"X.java",
+			"import java.io.IOException;\n" + 
+			"import java.nio.file.Files;\n" + 
+			"import java.nio.file.Path;\n" + 
+			"import java.util.function.Function;\n" + 
+			"import java.util.stream.Stream;\n" + 
+			"\n" + 
+			"public class X {\n" + 
+			"  public static void method() {\n" + 
+			"    Function<Path, Stream<Path>> method = Files::walk;\n" + 
+			"  }\n" + 
+			"}"
+		},
+		"----------\n" + 
+		"1. ERROR in X.java (at line 9)\n" + 
+		"	Function<Path, Stream<Path>> method = Files::walk;\n" + 
+		"	                                      ^^^^^^^^^^^\n" + 
+		"Unhandled exception type IOException\n" + 
+		"----------\n");
+}
 }
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
index 47e24d6..614a70c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
@@ -14,6 +14,7 @@
  *     Stephan Herrmann - Contribution for
  *								Bug 400874 - [1.8][compiler] Inference infrastructure should evolve to meet JLS8 18.x (Part G of JSR335 spec)
  *								Bug 423504 - [1.8] Implement "18.5.3 Functional Interface Parameterization Inference"
+ *								Bug 424742 - [1.8] NPE in LambdaExpression.isCompatibleWith
  *******************************************************************************/
 package org.eclipse.jdt.core.tests.compiler.regression;
 
@@ -2158,6 +2159,33 @@
 		"second\n" + 
 		"third");
 }
+public void testBug424742() {
+	runNegativeTest(
+		new String[] {
+			"TestInlineLambdaArray.java",
+			"package two.test;\n" + 
+			"\n" + 
+			"class TestInlineLambdaArray {\n" + 
+			"	TestInlineLambdaArray h = new TestInlineLambdaArray(x -> x++);	// [9]\n" + 
+			"	public TestInlineLambda(FI fi) {}\n" + 
+			"}\n" + 
+			"\n" + 
+			"interface FI {\n" + 
+			"		void foo();\n" + 
+			"}\n"
+		},
+		"----------\n" + 
+		"1. ERROR in TestInlineLambdaArray.java (at line 4)\n" + 
+		"	TestInlineLambdaArray h = new TestInlineLambdaArray(x -> x++);	// [9]\n" + 
+		"	                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+		"The constructor TestInlineLambdaArray((<no type> x) -> x ++) is undefined\n" + 
+		"----------\n" + 
+		"2. ERROR in TestInlineLambdaArray.java (at line 5)\n" + 
+		"	public TestInlineLambda(FI fi) {}\n" + 
+		"	       ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+		"Return type for the method is missing\n" + 
+		"----------\n");
+}
 public static Class testClass() {
 	return LambdaExpressionsTest.class;
 }
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index 9ec77e3..ae6cdec 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -3316,4 +3316,46 @@
 			true,
 			getCompilerOptions());		
 	}
+
+	// should not try to analyze arguments of a polymorphic method call
+	public void testBug424725() {
+		runConformTest(
+			new String[] {
+				"AnnotatedRecordMapper.java",
+				"import java.lang.invoke.MethodHandle;\n" + 
+				"\n" + 
+				"public final class AnnotatedRecordMapper<T> {\n" + 
+				"  private MethodHandle afterLoadStore;\n" + 
+				"\n" + 
+				"  public void invokeAfterLoadStore(Object object, Object database) {\n" + 
+				"    if(afterLoadStore != null) {\n" + 
+				"      try {\n" + 
+				"        afterLoadStore.invoke(object, database);\n" + 
+				"      }\n" + 
+				"      catch(Throwable e) {\n" + 
+				"        throw new RuntimeException(e);\n" + 
+				"      }\n" + 
+				"    }\n" + 
+				"  }\n" + 
+				"}"
+			});
+	}
+
+	public void testBug424727() {
+		runNegativeTestWithLibs(
+			new String[] {
+				"X.java",
+				"@org.eclipse.jdt.annotation.NonNull public class X {\n" +
+				"	static X singleton = new X();\n" +
+				"}\n"
+			},
+			getCompilerOptions(),
+			"----------\n" + 
+			"1. ERROR in X.java (at line 1)\n" + 
+			"	@org.eclipse.jdt.annotation.NonNull public class X {\n" + 
+			"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
+			"The nullness annotation \'NonNull\' is not applicable at this location\n" + 
+			"----------\n");
+		// note: to be updated with https://bugs.eclipse.org/415918
+	}
 }
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index a80f087..50b7b2a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -25,6 +25,7 @@
  *								Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
  *								Bug 417295 - [1.8[[null] Massage type annotated null analysis to gel well with deep encoded type bindings.
  *								Bug 400874 - [1.8][compiler] Inference infrastructure should evolve to meet JLS8 18.x (Part G of JSR335 spec)
+ *								Bug 424742 - [1.8] NPE in LambdaExpression.isCompatibleWith
  *     Jesper S Moller - Contributions for
  *								bug 382721 - [1.8][compiler] Effectively final variables needs special treatment
  *								bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
@@ -723,7 +724,9 @@
 			for (int i = 0, length = arguments == null ? 0 : arguments.length; i < length; i++) {
 				Expression argument = arguments[i];
 				TypeBinding updatedArgumentType = null;
-				TypeBinding parameterType = InferenceContext18.getParameter(parameters, i, variableArity); 
+				TypeBinding parameterType = InferenceContext18.getParameter(parameters, i, variableArity);
+				if (parameterType == null && problemReason != ProblemReasons.NoError)
+					continue; // not much we can do without a target type, assume it only happens after some resolve error
 
 				if (argument instanceof LambdaExpression && ((LambdaExpression) argument).hasErrors())
 					continue; // don't update if inner poly has errors
@@ -736,13 +739,7 @@
 						InferenceContext18 innerContext = innerInvocation.getInferenceContext(parameterizedMethod);
 						if (innerContext != null && !innerContext.hasFinished) {							
 							argument.setExpectedType(parameterType);
-							TypeBinding[] innerArgumentTypes = null;
-							if (innerArguments != null) {
-								innerArgumentTypes = new TypeBinding[innerArguments.length];
-								for (int j = 0; j < innerArguments.length; j++)
-									innerArgumentTypes[i] = innerArguments[i].resolvedType;
-							}
-							MethodBinding improvedBinding = innerContext.inferInvocationType(innerInvocation, innerArgumentTypes, parameterizedMethod);
+							MethodBinding improvedBinding = innerContext.inferInvocationType(innerInvocation, parameterizedMethod);
 							innerInvocation.updateBindings(improvedBinding);
 						}
 						continue; // otherwise these have been dealt with during inner method lookup
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index a6b05a2..24fcec6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -28,6 +28,7 @@
  *							Bug 417295 - [1.8[[null] Massage type annotated null analysis to gel well with deep encoded type bindings.
  *							Bug 418235 - [compiler][null] Unreported nullness error when using generic
  *							Bug 400874 - [1.8][compiler] Inference infrastructure should evolve to meet JLS8 18.x (Part G of JSR335 spec)
+ *							Bug 424727 - [compiler][null] NullPointerException in nullAnnotationUnsupportedLocation(ProblemReporter.java:5708)
  *     Jesper S Moller <jesper@selskabet.org> - Contributions for
  *							bug 378674 - "The method can be declared as static" is wrong
  *     Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
@@ -641,7 +642,8 @@
 		long nullTagBits = allocationType.tagBits & TagBits.AnnotationNullMASK;
 		if (nullTagBits != 0) {
 			Annotation annotation = this.type.findAnnotation(nullTagBits);
-			scope.problemReporter().nullAnnotationUnsupportedLocation(annotation);
+			if (annotation != null)
+				scope.problemReporter().nullAnnotationUnsupportedLocation(annotation);
 		}
 	}
 }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
index 809b65d..83c20fc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
@@ -99,6 +99,8 @@
 	// compare actual null-status against parameter annotations of the called method:
 	if (arguments != null) {
 		CompilerOptions compilerOptions = currentScope.compilerOptions();
+		if (compilerOptions.sourceLevel >= ClassFileConstants.JDK1_7 && methodBinding.isPolymorphic())
+			return;
 		boolean considerTypeAnnotations = compilerOptions.sourceLevel >= ClassFileConstants.JDK1_8
 				&& compilerOptions.isAnnotationBasedNullAnalysisEnabled;
 		boolean hasJDK15NullAnnotations = methodBinding.parameterNonNullness != null;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index 472bfe8..ded9714 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -18,6 +18,7 @@
  *								Bug 388630 - @NonNull diagnostics at line 0
  *								Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
  *								Bug 416176 - [1.8][compiler][null] null type annotations cause grief on type variables
+ *								Bug 424727 - [compiler][null] NullPointerException in nullAnnotationUnsupportedLocation(ProblemReporter.java:5708)
  *     Keigo Imai - Contribution for  bug 388903 - Cannot extend inner class as an anonymous class when it extends the outer class
  *******************************************************************************/
 package org.eclipse.jdt.internal.compiler.ast;
@@ -1710,6 +1711,7 @@
 						if (annotationType.id == TypeIds.T_ConfiguredAnnotationNonNull
 								|| annotationType.id == TypeIds.T_ConfiguredAnnotationNullable)
 						this.scope.problemReporter().nullAnnotationUnsupportedLocation(this.annotations[i]);
+						sourceType.tagBits &= ~TagBits.AnnotationNullMASK;
 					}
 				}
 			}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintFormula.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintFormula.java
index 7dd5f2a..9cc475d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintFormula.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintFormula.java
@@ -63,12 +63,15 @@
 		return variables;
 	}
 
-	public void applySubstitution(BoundSet solutionSet, InferenceVariable[] variables) {
+	public boolean applySubstitution(BoundSet solutionSet, InferenceVariable[] variables) {
 		for (int i=0; i<variables.length; i++) {
 			InferenceVariable variable = variables[i];
 			TypeBinding instantiation = solutionSet.getInstantiation(variables[i]);
+			if (instantiation == null)
+				return false;
 			this.right = this.right.substituteInferenceVariable(variable, instantiation);
 		}
+		return true;
 	}
 
 	// for debug toString():
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
index ea2d0bd..202657f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
@@ -302,13 +302,16 @@
 		return true;
 	}
 
-	public void applySubstitution(BoundSet solutionSet, InferenceVariable[] variables) {
+	public boolean applySubstitution(BoundSet solutionSet, InferenceVariable[] variables) {
 		super.applySubstitution(solutionSet, variables);
 		for (int i=0; i<variables.length; i++) {
 			InferenceVariable variable = variables[i];
 			TypeBinding instantiation = solutionSet.getInstantiation(variables[i]);
+			if (instantiation == null)
+				return false;
 			this.left = this.left.substituteInferenceVariable(variable, instantiation);
 		}
+		return true;
 	}
 
 	// debugging
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
index 3af11c1..6e64a4f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
@@ -335,7 +335,8 @@
 	}
 
 	/** JLS 18.5.2 Invocation Type Inference 
-	 * @param b1 "the bound set produced by reduction in order to demonstrate that m is applicable in 18.5.1" 
+	 * <p>Callers are responsible for any post-processing (see {@link #rebindInnerPolies(BoundSet, TypeBinding[])}).</p>
+	 * @param b1 "the bound set produced by reduction in order to demonstrate that m is applicable in 18.5.1"
 	 */
 	public BoundSet inferInvocationType(BoundSet b1, TypeBinding expectedType, InvocationSite invocationSite, MethodBinding method)
 			throws InferenceFailureException 
@@ -406,7 +407,8 @@
 				while (bottomIt.hasNext()) {
 					ConstraintFormula constraint = ((ConstraintFormula)bottomIt.next());
 					if (solution != null)
-						constraint.applySubstitution(solution, variablesArray);
+						if (!constraint.applySubstitution(solution, variablesArray))
+							return null;
 				// * reduce and incorporate
 					if (!this.currentBounds.reduceOneConstraint(this, constraint))
 						return null;
@@ -433,17 +435,34 @@
 	 * @return a valid method binding with updated type parameters,
 	 * 	or a problem method binding signaling either inference failure or a bound mismatch.
 	 */
-	public /*@NonNull*/ MethodBinding inferInvocationType(Invocation invocation, TypeBinding[] argumentTypes, ParameterizedGenericMethodBinding method) {
+	/*@NonNull*/ MethodBinding inferInvocationType(Invocation invocation, TypeBinding[] argumentTypes, ParameterizedGenericMethodBinding method) {
 		// TODO optimize: if outerContext exists and is resolved, we probably don't need to infer again.
 		TypeBinding targetType = invocation.invocationTargetType();
-		ParameterizedGenericMethodBinding finalMethod = method;
+		ParameterizedGenericMethodBinding finalMethod = null;
 		ParameterizedGenericMethodBinding methodToCheck = method;
-		
+				
 		boolean haveProperTargetType = targetType != null && targetType.isProperType(true);
 		if (haveProperTargetType) {
-			finalMethod = getInvocationTypeInferenceSolution(method.originalMethod, invocation, targetType);
+			MethodBinding original = method.originalMethod;
+			// start over from a previous candidate but discard its type variable instantiations
+			// TODO: should we retain any instantiations of type variables not owned by the method? 
+			BoundSet result = null;
+			try {
+				result = inferInvocationType(this.currentBounds, targetType, invocation, original);
+			} catch (InferenceFailureException e) {
+				// no solution, but do more checks below
+			}
+			if (result != null) {
+				TypeBinding[] solutions = getSolutions(original.typeVariables(), invocation, result);
+				if (solutions != null) {
+					finalMethod = this.environment.createParameterizedGenericMethod(original, solutions);
+					invocation.registerInferenceContext(finalMethod, this);
+				}
+			}
 			if (finalMethod != null)
 				methodToCheck = finalMethod;
+		} else {
+			finalMethod = method;
 		}
 		
 //{ObjectTeams: 2nd arg added:
@@ -467,31 +486,28 @@
 
 	/**
 	 * Simplified API to perform Invocation Type Inference (JLS 18.5.2)
-	 * and (if successful) return the solution.
-	 * @param site invocation being inferred
-	 * @param targetType target type for this invocation
-	 * @return a method binding with updated type parameters, or null if no solution was found
+	 * and perform subsequent steps: bound check, rebinding of inner poly expressions,
+	 * and creating of a problem method binding if needed.
+	 * Should only be called if the inference has not yet finished.
+	 * Version used for inner invocations, where argument types need to be extracted
+	 * from actual invocation arguments.
+	 * @param invocation invocation being inferred
+	 * @param method current candidate method binding for this invocation
+	 * @return a valid method binding with updated type parameters,
+	 * 	or a problem method binding signaling either inference failure or a bound mismatch.
 	 */
-	public ParameterizedGenericMethodBinding getInvocationTypeInferenceSolution(MethodBinding method, Invocation site, TypeBinding targetType) {
-		// start over from a previous candidate but discard its type variable instantiations
-		// TODO: should we retain any instantiations of type variables not owned by the method? 
-		BoundSet result = null;
-		try {
-			result = inferInvocationType(this.currentBounds, targetType, site, method);
-		} catch (InferenceFailureException e) {
-			return null;
+	public /*@NonNull*/ MethodBinding inferInvocationType(Invocation invocation, ParameterizedGenericMethodBinding method) {
+		TypeBinding[] argumentTypes = null;
+		Expression[] arguments = invocation.arguments();
+		if (arguments != null) {
+			argumentTypes = new TypeBinding[arguments.length];
+			for (int i = 0; i < arguments.length; i++)
+				argumentTypes[i] = arguments[i].resolvedType;
 		}
-		if (result != null) {
-			TypeBinding[] solutions = getSolutions(method.typeVariables(), site, result);
-			if (solutions != null) {
-				ParameterizedGenericMethodBinding substituteMethod = this.environment.createParameterizedGenericMethod(method, solutions);
-				site.registerInferenceContext(substituteMethod, this);
-				return substituteMethod;
-			}
-		}
-		return null;
+		return inferInvocationType(invocation, argumentTypes, method);
 	}
 
+
 	// ========== Below this point: implementation of the generic algorithm: ==========
 
 	/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
index b983290..e120f19 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
@@ -1512,7 +1512,9 @@
     					// Note: neither Ui nor Bi is necessarily scalar -> need to collect all bounds
     					TypeBinding[] otherUBounds = wildcard.otherBounds;
     					TypeBinding[] otherBBounds = typeParameters[i].otherUpperBounds();
-    					int len = 2 + (otherUBounds != null ? otherUBounds.length : 0) + otherBBounds.length;
+    					int len = 1 + (otherUBounds != null ? otherUBounds.length : 0) + otherBBounds.length;
+    					if (typeParameters[i].firstBound != null)
+    						len++;
     					ReferenceBinding[] allBounds = new ReferenceBinding[len];
     					try {
     						int idx = 0;
@@ -1522,7 +1524,8 @@
 	    						for (int j = 0; j < otherUBounds.length; j++)
 	    							allBounds[idx++] = (ReferenceBinding) otherUBounds[j];
 	    					// Bi
-	    					allBounds[idx++] = (ReferenceBinding) typeParameters[i].firstBound;
+	    					if (typeParameters[i].firstBound != null)
+	    						allBounds[idx++] = (ReferenceBinding) typeParameters[i].firstBound;
 	    					for (int j = 0; j < otherBBounds.length; j++)
 	    						allBounds[idx++] = (ReferenceBinding) otherBBounds[j];
     					} catch (ClassCastException cce) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index c195e9d..cfdc425 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -833,8 +833,12 @@
 			Invocation invocation = (Invocation) site;
 			if (method instanceof ParameterizedGenericMethodBinding) {
 				InferenceContext18 infCtx = invocation.getInferenceContext((ParameterizedGenericMethodBinding) method);
-				if (infCtx != null)
-					return COMPATIBLE; // inference is responsible, no need to recheck
+				if (infCtx != null) {
+					// inference is responsible, no need to recheck
+					if (infCtx.isVarArgs())
+						return VARARGS_COMPATIBLE;
+					return COMPATIBLE;
+				}
 			}
 			// collect inner invocations where the outer did not involve any inference:
 			Expression[] invocationArguments = invocation.arguments();
@@ -853,21 +857,19 @@
 						TypeBinding resolvedType = invocArg.resolvedType; 
 						if (!resolvedType.isCompatibleWith(targetType, this)) {
 							MethodBinding innerBinding = innerPoly.binding();
-							if (innerBinding instanceof ParameterizedGenericMethodBinding) { // FIXME: does this happen?
-								InferenceContext18 infCtx18 = innerPoly.getInferenceContext((ParameterizedGenericMethodBinding) innerBinding);
-								if (infCtx18 != null) {
+							if (innerBinding instanceof ParameterizedGenericMethodBinding) {
+								ParameterizedGenericMethodBinding innerParameterized = (ParameterizedGenericMethodBinding) innerBinding;
+								InferenceContext18 infCtx18 = innerPoly.getInferenceContext(innerParameterized);
+								if (infCtx18 != null && !infCtx18.hasFinished) {
 									// not detected as compatible, because inference still needs to complete?
-									MethodBinding solution = infCtx18.getInvocationTypeInferenceSolution(
-																		innerPoly.binding().original(), innerPoly, targetType);
-									if (solution != null) {
+									invocArg.setExpectedType(targetType);
+									MethodBinding solution = infCtx18.inferInvocationType(innerPoly, innerParameterized);
+									if (solution != null && solution.isValidBinding()) {
+										innerPoly.updateBindings(solution);
 										if (solution.returnType != null && solution.returnType.isCompatibleWith(targetType, this))
 											return isVarArgs ? VARARGS_COMPATIBLE : COMPATIBLE;
-									} else {
-										MethodBinding problemMethod = infCtx18.getReturnProblemMethodIfNeeded(targetType, innerPoly.binding());
-										if (problemMethod != null && problemMethod.isValidBinding())
-											return COMPATIBLE;
-										return NOT_COMPATIBLE;
 									}
+									return NOT_COMPATIBLE;
 								} else if (innerPoly instanceof AllocationExpression) {
 									// not detected as compatible, because its a diamond whose type hasn't yet been inferred?
 									TypeBinding[] typeArguments = resolvedType.typeArguments();