| Summary: | [1.8][quick assist] Conversion from lambda to anonymous class results in compile error | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Noopur Gupta <noopur_gupta> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | rdtorres |
| Version: | 4.4 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Noopur Gupta
I faced this issue as well.
This is a patch to fix it:
--- StubUtility2.java
+++ StubUtility2.java
@@ -52,6 +52,7 @@
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.NodeFinder;
+import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.PrimitiveType;
import org.eclipse.jdt.core.dom.ReturnStatement;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
@@ -342,7 +343,33 @@
bindingReturnType= bindingReturnType.getErasure();
}
+ if (bindingReturnType.isParameterizedType() && bindingReturnType.getTypeArguments().length > 0){
+
+
+ Type baseType=ast.newSimpleType(ast.newSimpleName(bindingReturnType.getErasure().getName()));
+ ParameterizedType newInstantiatedType=ast.newParameterizedType(baseType);
+
+ List<Type> newInstTypeArgs=newInstantiatedType.typeArguments();
+
+ ITypeBinding[] types = bindingReturnType.getTypeArguments();
+ for(ITypeBinding bindingT : types){
+ if (bindingT.isWildcardType()) {
+ ITypeBinding bound= bindingT.getBound();
+ bindingT = (bound != null) ? bound : bindingT.getErasure();
+ }
+ Type typeArg=ASTNodeFactory.newType(ast,bindingT.getName());
+ newInstTypeArgs.add(typeArg);
+ }
+
+ decl.setReturnType2(newInstantiatedType);
+
+
+ } else {
+
+
+
decl.setReturnType2(imports.addImport(bindingReturnType, ast, context));
+ }
List<SingleVariableDeclaration> parameters= createParameters(javaProject, imports, context, ast, binding, parameterNames, decl);
(In reply to Rafael Torres from comment #1) > I faced this issue as well. > > This is a patch to fix it: You patch does not fix the issue mentioned in comment #0. This bug is a duplicate of bug 439637 and works if "this" is added to the method invocation in lambda body: return (V v) -> this.apply(before.apply(v)); Please check if you have the same issue and if not, create a new bug report and provide the patch based on: https://wiki.eclipse.org/JDT_UI/How_to_Contribute#Contributing_a_change *** This bug has been marked as a duplicate of bug 439637 *** |