Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316904

Summary: [assist] completion for ctor with declared lifting causes CCE
Product: [Tools] Objectteams Reporter: Stephan Herrmann <stephan.herrmann>
Component: OTDTAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.7   
Target Milestone: 0.7   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
fix none

Description Stephan Herrmann CLA 2010-06-15 09:36:15 EDT
In the stopwatch example when typing
  new Wa
and hitting Ctrl-space, the following exception occurs:

java.lang.ClassCastException: org.eclipse.objectteams.otdt.internal.core.compiler.ast.LiftingTypeReference cannot be cast to org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference
at org.eclipse.jdt.internal.core.search.BasicSearchEngine$1AllConstructorDeclarationsVisitor.visit(BasicSearchEngine.java:787)
at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.traverse(ConstructorDeclaration.java:808)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:2061)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:808)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchAllConstructorDeclarations(BasicSearchEngine.java:838)
at org.eclipse.jdt.internal.core.SearchableEnvironment.findConstructorDeclarations(SearchableEnvironment.java:595)
at org.eclipse.jdt.internal.codeassist.CompletionEngine.findTypesAndPackages(CompletionEngine.java:10958)
at org.eclipse.jdt.internal.codeassist.CompletionEngine.completionOnSingleTypeReference(CompletionEngine.java:3320)
at org.eclipse.jdt.internal.codeassist.CompletionEngine._OT$complete$orig(CompletionEngine.java:1687)
at org.eclipse.jdt.internal.codeassist.CompletionEngine._OT$complete$chain(CompletionEngine.java)
at org.eclipse.jdt.internal.codeassist.CompletionEngine._OT$complete$chain(CompletionEngine.java)
at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java)
at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1947)
Comment 1 Stephan Herrmann CLA 2010-06-15 09:50:20 EDT
Created attachment 171930 [details]
fix

The CCE is caused by incomplete conditional:
testing "instanceof SingleTypeReference" and if false assuming it's a
QualifiedTypeReference.

OT/J has two more kinds of TypeReference: LiftingTypeReference and 
TypeAnchorReference. A full search for "instanceof SingleTypeReference"
brings three suspecious occurrences:
+ BasicSearchEngine, nested class inside searchAllConstructorDeclarations(..)
  -> that's what caused the CCE, fixed by also checking for LiftingTypeReference
+ JavadocArgumentExpression.internalResolveType(..)
  -> another missing check for LTR, also fixed in the patch
- TypeParameterLocator#match(TypeReference,MatchingNodeSet)
  -> may need to check for TypeAnchorReference
     NOT INCLUDED IN THIS PATCH.
Comment 2 Stephan Herrmann CLA 2010-06-15 09:51:32 EDT
Patch released as r515.
Comment 3 Stephan Herrmann CLA 2010-07-02 13:02:59 EDT
Verified using build 201007011455.