Bug 322664

Summary: fixing a broken generic type can give an IllegalStateException
Product: [Tools] AspectJ Reporter: Andrew Clement <aclement>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: DEVELOPMENT   
Target Milestone: 1.6.10   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Andrew Clement CLA 2010-08-13 11:15:26 EDT
Revealed by this program:

public abstract aspect AbstractAspect<S, T> {
 declare parents : Class extends S;
 declare parents : Class extends T;
}

aspect Aspect extends AbstractAspect<X, Y> {
/* void something(X x) {
  something(new Class());
 }
 void something2(Y y) {
  something2(new Class());
 }*/
}

interface X { }
interface Y { }

class Class {


}

1. save it like that
2. change AbstractAspect to remove ',T' from the declaration - results in error on save
3. fix the error (add ', T' back again) and save, IllegalStateException
Comment 1 Andrew Clement CLA 2010-08-13 11:16:48 EDT
The problem here is the ReferenceType is caching the TypeVariable information from the underlying delegate and not reseting it when the delegate is changed.  On the 3rd build (that fixes the problem) the delegate is correct for aspect but the ReferenceType.typeVariables field still points to the old broken single variable version.  By clearing the cached state when the delegate is reset (in ReferenceType.ensureConsistent) - the problem is fixed.
Comment 2 Andrew Clement CLA 2010-08-13 11:45:07 EDT
test and fix committed