| Summary: | [1.8] CCE in TypeBinding.isCastCompatible for PolyTypeBinding | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> | ||||
| Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | noopur_gupta, shankhba, srikanth_sankaran | ||||
| Version: | 4.4 | ||||||
| Target Milestone: | BETA J8 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 423585 | ||||||
| Attachments: |
|
||||||
There are more places where PolyTypeBinding cannot be cast to ReferenceBinding, e.g. from bug 423585 Issue 2 2): 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) PolyTypeBinding is a placeholder/proxy for the type of an expression that cannot be typed "yet". These should vanish from the picture be replaced by the correct type once the deferred typing is complete or by either null or a ProblemReferenceBinding if the context does not furnish a valid type. This last step is missing. Should be a straightforward fix. I'll work on it tomorrow. Working on it. Shankha, do you see this problem after pulling in http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=a98d7d87df415161ba75f53acbdbe8d316ea160c ? I don't. The problem is resolved after pulling n from the latest code. Thanks I do - I don't quite know how to consistently see it though. Created attachment 238326 [details]
Patch under test
I noticed an egregiously bad coding pattern that looks like:
return this.resolvedType = new PolyTypeBinding();
That is not correct since we are in no position to set the resolvedType field
at that point (i.e in an invocation context, with no expected type ...). This
also has the potential to leak PolyTypeBindings to escape the overload resolution
process and leak into perpetuity.
Patch under test
(In reply to Srikanth Sankaran from comment #7) > Created attachment 238326 [details] [diff] > Patch under test Verified that the patch resolves the CCE issue. (In reply to Noopur Gupta from comment #8) > (In reply to Srikanth Sankaran from comment #7) > > Created attachment 238326 [details] [diff] > > Patch under test > Verified that the patch resolves the CCE issue. Thanks Noopur. All JDT/Core tests are green. Released the fix here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=3a372fa727520c809be84deca2b7b9c51a2e6869 *** Bug 423574 has been marked as a duplicate of this bug. *** |
CCE when hovering over the reference to 'goo'. Note that 'I' is not a functional interface, and the compiler correctly reports errors for that. interface I { } public class X { static void goo(I i) { System.out.println("goo(I)"); } public static void main(String[] args) { goo(s -> 0); // hover over 'goo' -> CCE } } 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.internal.compiler.ast.Expression.checkCastTypesCompatibility(Expression.java:504) at org.eclipse.jdt.core.dom.TypeBinding.isCastCompatible(TypeBinding.java:1056) at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.doEqualNumberOfParameters(UnresolvedElementsSubProcessor.java:1599) at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.addParameterMissmatchProposals(UnresolvedElementsSubProcessor.java:1336) at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.getMethodProposals(UnresolvedElementsSubProcessor.java:1109) at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:337) at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections(QuickFixProcessor.java:300) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(JavaCorrectionProcessor.java:378) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.run(JavaCorrectionProcessor.java:339) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.process(JavaCorrectionProcessor.java:335) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:468) at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getJavaAnnotationFixes(ProblemHover.java:225) at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getCompletionProposals(ProblemHover.java:199) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.deferredCreateContent(AbstractAnnotationHover.java:285) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.setInput(AbstractAnnotationHover.java:186) at org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(AbstractInformationControlManager.java:1181) at org.eclipse.jface.text.AbstractInformationControlManager.presentInformation(AbstractInformationControlManager.java:1150) at org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation(AbstractHoverInformationControlManager.java:902) at org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation(TextViewerHoverManager.java:243) at org.eclipse.jface.text.TextViewerHoverManager$5.run(TextViewerHoverManager.java:233) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4145) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762)