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 (+31 lines)
Lines 2653-2657 Link Here
2653
		typeBinding = type.resolveBinding();
2653
		typeBinding = type.resolveBinding();
2654
		assertFalse("A Functional interface", typeBinding.isFunctionalInterface());
2654
		assertFalse("A Functional interface", typeBinding.isFunctionalInterface());
2655
	}
2655
	}
2656
	/**
2657
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=399793
2658
	 * 
2659
	 * @throws JavaModelException
2660
	 */
2661
	public void test417017() throws JavaModelException {
2662
		this.workingCopy = getWorkingCopy("/Converter18/src/test417017/X.java",
2663
				true/* resolve */);
2664
		String contents = "package test417017;"
2665
				+ "interface I {\n"
2666
				+ "	int foo(int x);\n"
2667
				+ "}\n" 
2668
				+ "public class X {\n"
2669
				+ " void fun(int a) {\n"
2670
				+"  	I i1 = x1-> x1;\n"
2671
				+"  	I i2 = xxx-> {\n"
2672
				+"  		i1.foo(a);\n"
2673
				+"  		return xxx;\n"
2674
				+"  	};\n"
2675
				+"  }\n"
2676
				+"}\n";
2677
		CompilationUnit cu = (CompilationUnit) buildAST(contents, this.workingCopy);
2678
		TypeDeclaration typedeclaration = (TypeDeclaration) getASTNode(cu, 1);
2679
		MethodDeclaration methodDeclaration = typedeclaration.getMethods()[0];
2680
		VariableDeclarationFragment vdf= (VariableDeclarationFragment) ((VariableDeclarationStatement) methodDeclaration.getBody().statements().get(1)).fragments().get(0);
2681
		LambdaExpression lambda= (LambdaExpression) vdf.getInitializer();
2682
		List parameters = lambda.parameters();
2683
		assertTrue("Incorrect Number of parameters", parameters.size() == 1);
2684
		ITypeBinding[] parameterTypes= lambda.resolveMethodBinding().getParameterTypes();
2685
		assertTrue("Incorrect Number of parameter type", parameterTypes.length == 1);
2686
	}
2656
2687
2657
}
2688
}
(-)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.isSynthetic() ? 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