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

Bug 326098

Summary: [compiler] NPE when base ctor with arg lowering is used as an expression
Product: [Tools] Objectteams Reporter: Stephan Herrmann <stephan.herrmann>
Component: OTJAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.7   
Target Milestone: 0.7.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
fix none

Description Stephan Herrmann CLA 2010-09-23 16:12:57 EDT
This was observed when simplifying OTTypeHierarchyes.ConnectedPhantomType
and has been reconstructed as test236_constructorWithBasecall7():

when leveraging bug 323862 in a situation where an argument to the
base constructor requires lowering, the following NPE would occur:

Caused by: java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:1322)
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:1308)
	at org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.InsertTypeAdjustmentsVisitor.maybeWrap(InsertTypeAdjustmentsVisitor.java:279)
	at org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.InsertTypeAdjustmentsVisitor.endVisit(InsertTypeAdjustmentsVisitor.java:76)
	at org.eclipse.jdt.internal.compiler.ast.Assignment.traverse(Assignment.java:273)
	at org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseAllocationExpression.traverse(BaseAllocationExpression.java:333)
	at org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall.traverse(ExplicitConstructorCall.java:829)
	at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.resolveStatements(ConstructorDeclaration.java:793)
 ...
Comment 1 Stephan Herrmann CLA 2010-09-23 16:24:59 EDT
Created attachment 179486 [details]
fix

The lowering request triggered the InsertTypeAdjustmentsVisitor,
which traversed the BaseAllocationExpression as an Assignment,
but the lhs has not been developed (i.e., resolved), because
the node actually is not a statement but an expression,
thus the NPE.

Fixed by one more check for isExpression.
Comment 2 Stephan Herrmann CLA 2010-09-23 16:28:32 EDT
Patch has been committed as r835.
Comment 3 Stephan Herrmann CLA 2010-09-23 18:32:34 EDT
Verified using I201009231632