Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 417017 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java (+62 lines)
Lines 2645-2650 Link Here
2645
		typeBinding = type.resolveBinding();
2645
		typeBinding = type.resolveBinding();
2646
		assertFalse("A Functional interface", typeBinding.isFunctionalInterface());
2646
		assertFalse("A Functional interface", typeBinding.isFunctionalInterface());
2647
	}
2647
	}
2648
	/**
2649
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=417017
2650
	 * 
2651
	 * @throws JavaModelException
2652
	 */
2653
	public void test417017a() throws JavaModelException {
2654
		this.workingCopy = getWorkingCopy("/Converter18/src/test417017/X.java",
2655
				true/* resolve */);
2656
		String contents = "package test417017;"
2657
				+ "interface I {\n"
2658
				+ "	int foo(int x);\n"
2659
				+ "}\n" 
2660
				+ "public class X {\n"
2661
				+ " void fun(int a) {\n"
2662
				+"  	I i1 = x1-> x1;\n"
2663
				+"  	I i2 = xxx-> {\n"
2664
				+"  		i1.foo(a);\n"
2665
				+"  		return xxx;\n"
2666
				+"  	};\n"
2667
				+"  }\n"
2668
				+"}\n";
2669
		CompilationUnit cu = (CompilationUnit) buildAST(contents, this.workingCopy);
2670
		TypeDeclaration typedeclaration = (TypeDeclaration) getASTNode(cu, 1);
2671
		MethodDeclaration methodDeclaration = typedeclaration.getMethods()[0];
2672
		VariableDeclarationFragment vdf= (VariableDeclarationFragment) ((VariableDeclarationStatement) methodDeclaration.getBody().statements().get(1)).fragments().get(0);
2673
		LambdaExpression lambda= (LambdaExpression) vdf.getInitializer();
2674
		List parameters = lambda.parameters();
2675
		assertTrue("Incorrect Number of parameters", parameters.size() == 1);
2676
		ITypeBinding[] parameterTypes= lambda.resolveMethodBinding().getParameterTypes();
2677
		assertTrue("Incorrect Number of parameter type", parameterTypes.length == 1);
2678
	}
2679
	/**
2680
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=417017
2681
	 * 
2682
	 * @throws JavaModelException
2683
	 */
2684
	public void test417017b() throws JavaModelException {
2685
		this.workingCopy = getWorkingCopy("/Converter18/src/test417017/X.java",
2686
				true/* resolve */);
2687
		String contents = "package test417017;" +
2688
				"interface I1 {\n" +
2689
				"	int foo(int a);\n" +
2690
				"}\n" +
2691
				"\n" +
2692
				"interface I2 {\n" +
2693
				"	public default int foo() {\n" +
2694
				"		I1 i1 = (a) -> {\n" +
2695
				"			return a;\n" +
2696
				"		};\n" +
2697
				"		//return 0;\n" + // Error on purpose
2698
				"	}\n" +
2699
				"}\n" ;
2700
		CompilationUnit cu = (CompilationUnit) buildAST(contents, this.workingCopy, false);
2701
		TypeDeclaration typedeclaration = (TypeDeclaration) getASTNode(cu, 1);
2702
		MethodDeclaration methodDeclaration = typedeclaration.getMethods()[0];
2703
		VariableDeclarationFragment vdf= (VariableDeclarationFragment) ((VariableDeclarationStatement) methodDeclaration.getBody().statements().get(0)).fragments().get(0);
2704
		LambdaExpression lambda= (LambdaExpression) vdf.getInitializer();
2705
		List parameters = lambda.parameters();
2706
		assertTrue("Incorrect Number of parameters", parameters.size() == 1);
2707
		ITypeBinding[] parameterTypes= lambda.resolveMethodBinding().getParameterTypes();
2708
		assertTrue("Incorrect Number of parameter type", parameterTypes.length == 1);
2709
	}
2648
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=413942
2710
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=413942
2649
	// also refer https://bugs.eclipse.org/bugs/show_bug.cgi?id=413569
2711
	// also refer https://bugs.eclipse.org/bugs/show_bug.cgi?id=413569
2650
	public void testBug413942() throws JavaModelException {
2712
	public void testBug413942() throws JavaModelException {
(-)a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java (-5 / +23 lines)
Lines 1-11 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 *
12
* Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
14
 *******************************************************************************/
11
15
Lines 13-23 Link Here
13
17
14
import org.eclipse.jdt.core.IJavaElement;
18
import org.eclipse.jdt.core.IJavaElement;
15
import org.eclipse.jdt.core.JavaCore;
19
import org.eclipse.jdt.core.JavaCore;
20
import org.eclipse.jdt.internal.compiler.ast.Argument;
21
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
16
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
22
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
17
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
23
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
18
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
24
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
19
import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
20
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
21
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
22
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
23
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
30
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
Lines 123-128 Link Here
123
		return this.annotations = AnnotationBinding.NoAnnotations;
130
		return this.annotations = AnnotationBinding.NoAnnotations;
124
	}
131
	}
125
132
133
	private int getActualStart(SyntheticMethodBinding sam, int length) {
134
		int start = 0;
135
		LambdaExpression lambda = sam.lambda;
136
		Argument[] arguments = null;
137
		if (lambda != null && (arguments = lambda.arguments) != null) {
138
			start = length - arguments.length;
139
		}
140
		return start;
141
	}
142
126
	/**
143
	/**
127
	 * @see IMethodBinding#getDeclaringClass()
144
	 * @see IMethodBinding#getDeclaringClass()
128
	 */
145
	 */
Lines 175-189 Link Here
175
		if (length == 0) {
192
		if (length == 0) {
176
			return this.parameterTypes = NO_TYPE_BINDINGS;
193
			return this.parameterTypes = NO_TYPE_BINDINGS;
177
		} else {
194
		} else {
178
			ITypeBinding[] paramTypes = new ITypeBinding[length];
195
			int start = this.binding instanceof SyntheticMethodBinding ? getActualStart((SyntheticMethodBinding) this.binding, length) : 0;
179
			for (int i = 0; i < length; i++) {
196
			ITypeBinding[] paramTypes = new ITypeBinding[length - start];
197
			for (int i = start; i < length; i++) {
180
				final TypeBinding parameterBinding = parameters[i];
198
				final TypeBinding parameterBinding = parameters[i];
181
				if (parameterBinding != null) {
199
				if (parameterBinding != null) {
182
					ITypeBinding typeBinding = this.resolver.getTypeBinding(parameterBinding);
200
					ITypeBinding typeBinding = this.resolver.getTypeBinding(parameterBinding);
183
					if (typeBinding == null) {
201
					if (typeBinding == null) {
184
						return this.parameterTypes = NO_TYPE_BINDINGS;
202
						return this.parameterTypes = NO_TYPE_BINDINGS;
185
					}
203
					}
186
					paramTypes[i] = typeBinding;
204
					paramTypes[i - start] = typeBinding;
187
				} else {
205
				} else {
188
					// log error
206
					// log error
189
					StringBuffer message = new StringBuffer("Report method binding where a parameter is null:\n");  //$NON-NLS-1$
207
					StringBuffer message = new StringBuffer("Report method binding where a parameter is null:\n");  //$NON-NLS-1$

Return to bug 417017