Bug 507254 - Run tests with assertions enabled
- fix AssertionError in ProblemReporter.invalidMethod
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 88b5e90..0a12450 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -4446,8 +4446,22 @@
return;
// creator calls should be reported as constructors:
if (CopyInheritance.isCreator(method)) {
- // must be handled in AllocationExpression:
- assert (method.problemId() != ProblemReasons.NonStaticReferenceInStaticContext);
+ switch (method.problemId()) {
+ // for roles we detect this earlier than JDT
+ case ProblemReasons.NonStaticReferenceInConstructorInvocation:
+ case ProblemReasons.NonStaticReferenceInStaticContext:
+ if ( method.declaringClass != null
+ && method.declaringClass.isRole())
+ {
+ ASTNode invocation = (messageSend instanceof CopyInheritance.RoleConstructorCall)
+ ? ((RoleConstructorCall)messageSend).allocationOrig
+ : messageSend;
+ noSuchEnclosingInstance(method.declaringClass.enclosingType(), invocation,
+ method.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation);
+ return;
+ }
+ break;
+ }
if (messageSend.actualReceiverType instanceof SourceTypeBinding) {
TypeDeclaration receiverType = null;