Community
Participate
Working Groups
package test; import java.util.function.Supplier; public class Bug { private void fun1() { Runnable runnable = () -> { System.out.println("hi"); }; foo((x) -> runnable); // Error [1] bar(() -> runnable); // Error [2] } private void foo(String c) {} private void bar(L c) {} } interface L { int fx(int x); } ---------------------------------------------------------------- Consider the above example having 2 compilation errors at the locations [1] and [2]. Hover over the method name in the method invocation at [1] and [2]. Issue 1: The error reported at [1] is: "The method foo(String) in the type Bug is not applicable for the arguments ((<no type> x) -> runnable)" --> "((<no type> x) -> runnable)" : Is this OK? Issue 2: The quick fixes suggested at [1] are invalid and result in exceptions: 1) Change method 'foo(String)' to 'foo((<no type> x) -> runnable)' : java.lang.UnsupportedOperationException at org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding.getPackage(PolyTypeBinding.java:33) at org.eclipse.jdt.core.dom.TypeBinding.getQualifiedName(TypeBinding.java:814) at org.eclipse.jdt.core.dom.rewrite.ImportRewrite.getRawQualifiedName(ImportRewrite.java:1001) at org.eclipse.jdt.core.dom.rewrite.ImportRewrite.addImport(ImportRewrite.java:720) at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatureProposal.modifyParameters(ChangeMethodSignatureProposal.java:217) ... 2) Create method 'foo((<no type> x) -> runnable)' : java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding at org.eclipse.jdt.core.dom.TypeBinding.getInterfaces(TypeBinding.java:501) at org.eclipse.jdt.internal.ui.text.correction.ASTResolving.collectRelaxingTypes(ASTResolving.java:1000) at org.eclipse.jdt.internal.ui.text.correction.ASTResolving.getRelaxingTypes(ASTResolving.java:994) at org.eclipse.jdt.internal.ui.text.correction.proposals.NewMethodCorrectionProposal.evaluateParameterType(NewMethodCorrectionProposal.java:260) at org.eclipse.jdt.internal.ui.text.correction.proposals.NewMethodCorrectionProposal.addNewParameters(NewMethodCorrectionProposal.java:239) ... Issue 3: The quick fix suggested at [2] is invalid: - Create method 'bar(L)'
> Issue 1: The error reported at [1] is: > "The method foo(String) in the type Bug is not applicable for the arguments > ((<no type> x) -> runnable)" > --> "((<no type> x) -> runnable)" : Is this OK? It's not super pretty, but the "<no type>" part could actually help the user understand the problem. We might take that up later when the rest of the infrastructure is done and we have the final set of error messages. > Issue 2: The quick fixes suggested at [1] are invalid and result in > exceptions: > > 1) Change method 'foo(String)' to 'foo((<no type> x) -> runnable)' : > java.lang.UnsupportedOperationException > at > org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding. > getPackage(PolyTypeBinding.java:33) That's bug 423574. > 2) Create method 'foo((<no type> x) -> runnable)' : > java.lang.ClassCastException: > org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding cannot be cast to > org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding > at org.eclipse.jdt.core.dom.TypeBinding.getInterfaces(TypeBinding.java:501) > at > org.eclipse.jdt.internal.ui.text.correction.ASTResolving. > collectRelaxingTypes(ASTResolving.java:1000) I've added a note to bug 423582.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.