tuning generics, member enums
diff --git a/buildnotes_jdt-core.html b/buildnotes_jdt-core.html
index 14b7e4e..9458788 100644
--- a/buildnotes_jdt-core.html
+++ b/buildnotes_jdt-core.html
@@ -97,7 +97,11 @@
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=76880">76880</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=74851">74851</a>
+[1.5] enum errors in 3.1M1
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=75134">75134</a>
+[1.5] Type mismatch error generated
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=76880">76880</a>
Unable to resolve enum type
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=76766">76766</a>
[1.5] Option to format empty enum declaration or empty enum constant body has no effect
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index 2076364..bca8299 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -199,8 +199,8 @@
}
if (unsafeWildcardInvocation) {
scope.problemReporter().wildcardInvocation((ASTNode)invocationSite, receiverType, method, argumentTypes);
- } else if (receiverType.isRawType() && method.hasSubstitutedParameters()) {
- scope.problemReporter().unsafeRawInvocation((ASTNode)invocationSite, receiverType, method);
+ } else if (!receiverType.isUnboundWildcard() && method.declaringClass.isRawType() && method.hasSubstitutedParameters()) {
+ scope.problemReporter().unsafeRawInvocation((ASTNode)invocationSite, method);
}
}
public ASTNode concreteStatement() {
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java b/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
index 367bcc4..745d613 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
@@ -139,6 +139,12 @@
return null;
}
ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
+ if (qualifiedType == null) {
+ qualifiedType = currentType.enclosingType(); // if member type
+ if (qualifiedType != null && currentType.isStatic() && qualifiedType.isGenericType()) {
+ qualifiedType = scope.environment().createRawType(qualifiedType, qualifiedType.enclosingType());
+ }
+ }
if (typeIsConsistent && currentType.isStatic() && qualifiedType != null && (qualifiedType.isParameterizedType() || qualifiedType.isGenericType())) {
scope.problemReporter().staticMemberOfParameterizedType(this, scope.createParameterizedType(currentType, null, qualifiedType));
typeIsConsistent = false;
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java b/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
index 3a44879..2fdfc2e 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
@@ -102,6 +102,13 @@
reportInvalidType(scope);
return null;
}
+ enclosingType = this.resolvedType.enclosingType(); // if member type
+ if (enclosingType != null) {
+ ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
+ if (currentType.isStatic() && enclosingType.isGenericType()) {
+ enclosingType = scope.environment().createRawType(enclosingType, enclosingType.enclosingType());
+ }
+ }
} else { // resolving member type (relatively to enclosingType)
this.resolvedType = scope.getMemberType(token, (ReferenceBinding)enclosingType.erasure());
if (!this.resolvedType.isValidBinding()) {
diff --git a/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 0b637c2..bb2d2ba 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -365,6 +365,8 @@
modifiers |= AccDeprecatedImplicitly;
if ((enclosingType.modifiers & AccInterface) != 0)
modifiers |= AccPublic;
+ if (sourceType.isEnum())
+ modifiers |= AccStatic;
} else if (sourceType.isLocalType()) {
if (sourceType.isAnonymousType()) {
modifiers |= AccFinal;
diff --git a/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
index 398829b..5cba9cc 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
@@ -31,11 +31,8 @@
private ReferenceBinding enclosingType;
public ParameterizedTypeBinding(ReferenceBinding type, TypeBinding[] arguments, ReferenceBinding enclosingType, LookupEnvironment environment){
+
this.environment = environment;
- if (type.isParameterizedType() && type.isMemberType()) { // fixup instance of parameterized member type, e.g. Map<K,V>.Entry + <A,B>
- enclosingType = type.enclosingType(); // use enclosing from previously parameterized
- type = (ReferenceBinding)type.erasure(); // connect to erasure of member type
- }
initialize(type, arguments);
this.enclosingType = enclosingType; // never unresolved, never lazy per construction
diff --git a/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index 0243900..fbbc9eb 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -314,19 +314,12 @@
depth++;
return depth;
}
-/* Answer the receiver's enclosing type... null if the receiver is a top level type.
-*/
-
-public ReferenceBinding enclosingType() {
- return null;
-}
public final ReferenceBinding enclosingTypeAt(int relativeDepth) {
ReferenceBinding current = this;
while (relativeDepth-- > 0 && current != null)
current = current.enclosingType();
return current;
}
-
public int fieldCount() {
return fields().length;
}
diff --git a/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java b/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
index fefb9e2..0e32594 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
@@ -62,6 +62,12 @@
public int dimensions(){
return 0;
}
+/* Answer the receiver's enclosing type... null if the receiver is a top level type.
+*/
+
+public ReferenceBinding enclosingType() {
+ return null;
+}
public TypeBinding erasure() {
return this;
}
@@ -209,7 +215,12 @@
public boolean isBoundParameterizedType() {
return (this.tagBits & TagBits.IsBoundParameterizedType) != 0;
}
-
+/**
+ * Returns true if wildcard type of the form '?' (no bound)
+ */
+public boolean isUnboundWildcard() {
+ return false;
+}
/**
* Returns true if the type is a wildcard
*/
diff --git a/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java b/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
index f0bbd1e..6f345df 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
@@ -182,6 +182,13 @@
/**
* Returns true if the type is a wildcard
*/
+ public boolean isUnboundWildcard() {
+ return this.kind == Wildcard.UNBOUND;
+ }
+
+ /**
+ * Returns true if the type is a wildcard
+ */
public boolean isWildcard() {
return true;
}
@@ -272,15 +279,15 @@
*/
public ReferenceBinding[] superInterfaces() {
if (this.superInterfaces == null) {
- TypeBinding superType = null;
if (this.kind == Wildcard.EXTENDS) {
- superType = this.bound;
+ if (this.bound.isInterface()) {
+ return new ReferenceBinding[]{ (ReferenceBinding)this.bound };
+ } else {
+ return NoSuperInterfaces;
+ }
} else if (this.typeVariable() != null) {
- superType = this.typeVariable.firstBound; // TODO (philippe) shouldn't it retrieve variable superinterfaces ?
+ return this.typeVariable.superInterfaces();
}
- this.superInterfaces = superType != null && superType.isInterface()
- ? new ReferenceBinding[] { (ReferenceBinding) superType }
- : NoSuperInterfaces;
}
return this.superInterfaces;
}
diff --git a/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index ec0e593..62c0c45 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -4499,19 +4499,19 @@
location.sourceStart,
location.sourceEnd);
}
-public void unsafeRawInvocation(ASTNode location, TypeBinding receiverType, MethodBinding method) {
- if (method.isConstructor()) {
+public void unsafeRawInvocation(ASTNode location, MethodBinding rawMethod) {
+ if (rawMethod.isConstructor()) {
this.handle(
IProblem.UnsafeRawConstructorInvocation,
new String[] {
- new String(receiverType.readableName()),
- typesAsString(method.original().isVarargs(), method.original().parameters, false),
- new String(receiverType.erasure().readableName()),
+ new String(rawMethod.declaringClass.readableName()),
+ typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, false),
+ new String(rawMethod.declaringClass.erasure().readableName()),
},
new String[] {
- new String(receiverType.shortReadableName()),
- typesAsString(method.original().isVarargs(), method.original().parameters, true),
- new String(receiverType.erasure().shortReadableName()),
+ new String(rawMethod.declaringClass.shortReadableName()),
+ typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, true),
+ new String(rawMethod.declaringClass.erasure().shortReadableName()),
},
location.sourceStart,
location.sourceEnd);
@@ -4519,16 +4519,16 @@
this.handle(
IProblem.UnsafeRawMethodInvocation,
new String[] {
- new String(method.selector),
- typesAsString(method.original().isVarargs(), method.original().parameters, false),
- new String(receiverType.readableName()),
- new String(receiverType.erasure().readableName()),
+ new String(rawMethod.selector),
+ typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, false),
+ new String(rawMethod.declaringClass.readableName()),
+ new String(rawMethod.declaringClass.erasure().readableName()),
},
new String[] {
- new String(method.selector),
- typesAsString(method.original().isVarargs(), method.original().parameters, true),
- new String(receiverType.shortReadableName()),
- new String(receiverType.erasure().shortReadableName()),
+ new String(rawMethod.selector),
+ typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, true),
+ new String(rawMethod.declaringClass.shortReadableName()),
+ new String(rawMethod.declaringClass.erasure().shortReadableName()),
},
location.sourceStart,
location.sourceEnd);
diff --git a/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 79c10e4..a93529f 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -145,8 +145,8 @@
178 = The assignment to variable {0} has no effect
179 = Possible accidental assignment in place of a comparison. A condition expression should not be reduced to an assignment
180 = Unnecessary semicolon
-181 = Unnecessary cast to type {1} for expression of type {0}
-182 = Unnecessary cast to type {1} for expression of type {0}. It is already compatible with the argument type {2}
+181 = Unnecessary cast from {0} to {1}
+182 = Unnecessary cast from {0} to {1}. It is already compatible with the argument type {2}
183 = The expression of type {0} is already an instance of type {1}
184 = finally block does not complete normally
185 = The declared exception {3} is not actually thrown by the method {1}({2}) from type {0}
@@ -167,7 +167,7 @@
200 = Cannot use {0} in a static context
201 = Cannot make a static reference to the non-static method {1}({2}) from the type {0}
202 = Cannot specify an array dimension after an empty dimension
-203 = Invalid cast type expression
+203 = Invalid cast expression
204 = Syntax error on token "{0}", {1} expected
205 = Syntax error on token "{0}", no accurate correction available
206 = Invalid argument to operation ++/--
@@ -411,22 +411,22 @@
527 = Method {0}({2}) has the same erasure {0}({3}) as another method in type {1}
528 = Illegal forward reference to type parameter {0}
529 = The type {0} is not an interface; it cannot be specified as a bounded parameter
-530 = Unsafe type operation: Should not invoke the constructor {0}({1}) of raw type {0}. References to generic type {2} should be parameterized
-531 = Unsafe type operation: Should not invoke the method {0}({1}) of raw type {2}. References to generic type {3} should be parameterized
-532 = Unsafe type operation: Should not convert expression of raw type {0} to type {1}. References to generic type {2} should be parameterized
+530 = Type safety: The constructor {0}({1}) belongs to the raw type {0}. References to generic type {2} should be parameterized
+531 = Type safety: The method {0}({1}) belongs to the raw type {2}. References to generic type {3} should be parameterized
+532 = Type safety: The expression of raw type {0} is converted to {1}. References to generic type {2} should be parameterized
533 = Cannot use the type parameter {0} in a catch block
534 = Cannot use the parameterized type {0} either in catch block or throws clause
535 = Cannot create a generic array of {0}
-536 = Unsafe type operation: Should not assign expression of type {0} to the field {1} of raw type {2}. References to generic type {3} should be parameterized
+536 = Type safety: The field {1} from the raw type {2} is assigned a value of type {0}. References to generic type {3} should be parameterized
537 = The type parameter {0} should not be bounded by the final type {1}. Final types cannot be further extended
538 = Inconsistent classfile encountered: The undefined type parameter {0} is referenced from within {1}
-539 = The interface {2} cannot be implemented simultaneously with different arguments: {0} and {1}
+539 = The interface {2} cannot be implemented more than once with different arguments: {0} and {1}
540 = Bound mismatch: The constructor {0}({1}) of type {2} is not applicable for the arguments ({3}). The wildcard parameter {5} has no lower bound, and may actually be more restrictive than argument {4}
541 = Bound mismatch: The method {0}({1}) of type {2} is not applicable for the arguments ({3}). The wildcard parameter {5} has no lower bound, and may actually be more restrictive than argument {4}
542 = Bound mismatch: Cannot assign expression of type {0} to wildcard type {1}. The wildcard type has no lower bound, and may actually be more restrictive than expression type
543 = Bound mismatch: The generic method {0}({1}) of type {2} is not applicable for the arguments ({3}) since the type {4} is not a valid substitute for the bounded parameter <{5} extends {6}>
544 = Bound mismatch: The generic constructor {0}({1}) of type {2} is not applicable for the arguments ({3}) since the type {4} is not a valid substitute for the bounded parameter <{5} extends {6}>
-545 = Unsafe type operation: The cast from {0} to parameterized type {1} will not check conformance of type arguments at runtime
+545 = Type safety: The cast from {0} to {1} will not check conformance of type arguments at runtime
546 = Cannot perform instanceof check against parameterized type {0}. Use instead its raw form {1} since generic type information will be erased at runtime
547 = Cannot perform instanceof check against type parameter {0}. Use instead its erasure {1} since generic type information will be erased at runtime
548 = The method {0}({1}) of type {2} is not generic; it cannot be parameterized with arguments <{3}>
@@ -440,7 +440,7 @@
556 = The type {1} cannot extend or implement {0}. A supertype may not specify any wildcard
557 = The generic class {0} may not subclass java.lang.Throwable
558 = Illegal class literal for the type parameter {0}
-559 = Unsafe type operation: The return type {0} of the method {1}({2}) of type {3} needs unchecked conversion to conform to the return type {4} of inherited method
+559 = Type safety: The return type {0} of the method {1}({2}) of type {3} needs unchecked conversion to conform to the return type {4} of inherited method
560 = Name clash : The method {0}({1}) of type {2} has the same erasure as {0}({3}) of type {4} but does not override it
561 = The member type {0}<{1}> must be qualified with a parameterized type, since it is not static
562 = The member type {0} must be parameterized, since it is qualified with a parameterized type
diff --git a/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java b/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
index 009fd91..18b8a14 100644
--- a/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
+++ b/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
@@ -207,7 +207,7 @@
}
}
if (allocatedType.isRawType() && this.binding.hasSubstitutedParameters()) {
- scope.problemReporter().unsafeRawInvocation(this, allocatedType, this.binding);
+ scope.problemReporter().unsafeRawInvocation(this, this.binding);
}
return allocatedType;
}