public void testGenericITDComplex() {
runTest("more complex static member itd");
}
+
+// public void testGenericITFSharingTypeVariable() {
+// runTest("generic intertype field declaration, sharing type variable");
+// }
// public void testItdOnGenericType() {
// runTest("ITDs on generic type");
verifyClassSignature("Basic6","<J:Ljava/lang/Object;>Ljava/lang/Object;LI<TJ;>;LK<Ljava/lang/Integer;>;");
}
-// public void testGenericDecpIncorrectNumberOfTypeParams() {
-// runTest("generic decp - incorrect number of type parameters");
-// }
+ public void testGenericDecpIncorrectNumberOfTypeParams() {
+ runTest("generic decp - incorrect number of type parameters");
+ }
public void testGenericDecpSpecifyingBounds() {
runTest("generic decp - specifying bounds");
}
-// public void testGenericDecpViolatingBounds() {
-// runTest("generic decp - specifying bounds but breaking them");
-// }
+ public void testGenericDecpViolatingBounds() {
+ runTest("generic decp - specifying bounds but breaking them");
+ }
// need separate compilation test to verify signatures are ok
//
</run>
</ajc-test>
+ <ajc-test dir="java5/generics/itds" title="generic intertype field declaration, sharing type variable">
+ <compile files="FieldITDOnGeneric.aj" options="-1.5"/>
+ <run class="FieldITDOnGeneric">
+ <stderr>
+ <line text="foo"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
<ajc-test dir="java5/generics/itds" title="Parsing generic ITDs - 1">
<compile files="Parse1.java" options="-1.5"/>
</ajc-test>
<weave classesFiles="Base4.java" aspectsFiles="Asp4.aj" options="-1.5,-showWeaveInfo"/>
</ajc-test>
- <ajc-test dir="java5/generics/decp" title="generic decp - incorrect number of type parameters">
- <compile files="Basic3.aj" options="-1.5"/>
- <run class="Basic3"/>
- </ajc-test>
-
<ajc-test dir="java5/generics/decp" title="generic decp - incorrect number of type parameters">
<compile files="Basic3.aj" options="-1.5">
- <message kind="error" line="10" text="Wrong number of type arguments; Type I requires 1"/>
+ <message kind="error" line="10" text="Type pattern does not match because the wrong number of type parameters are specified: Type I requires 1 parameter(s)"/>
</compile>
</ajc-test>
<ajc-test dir="java5/generics/decp" title="generic decp - specifying bounds but breaking them">
<compile files="Basic5.aj" options="-1.5">
- <message kind="error" line="7" text="Type String does not meet the specification for type parameter 1 in generic type I<T extends Number>"/>
+ <message kind="error" line="7" text="Type java.lang.String does not meet the specification for type parameter 1 (T extends java.lang.Number) in generic type I"/>
</compile>
</ajc-test>
if (type == ResolvedType.MISSING) {
return resolveBindingsForMissingType(resolvedTypeInTheWorld, originalName, scope, bindings, allowBinding, requireExactType);
} else {
- return resolveBindingsForExactType(scope,type,fullyQualifiedName);
+ return resolveBindingsForExactType(scope,type,fullyQualifiedName,requireExactType);
}
}
- private TypePattern resolveBindingsForExactType(IScope scope, UnresolvedType aType, String fullyQualifiedName) {
+ private TypePattern resolveBindingsForExactType(IScope scope, UnresolvedType aType, String fullyQualifiedName,boolean requireExactType) {
TypePattern ret = null;
if (aType.isTypeVariableReference()) {
// we have to set the bounds on it based on the bounds of this pattern
ret = resolveBindingsForTypeVariable(scope, (UnresolvedTypeVariableReferenceType) aType);
} else if (typeParameters.size()>0) {
- if (!verifyTypeParameters(aType.resolve(scope.getWorld()),scope)) return TypePattern.NO; // messages already isued
+ if (!verifyTypeParameters(aType.resolve(scope.getWorld()),scope,requireExactType)) return TypePattern.NO; // messages already isued
// Only if the type is exact *and* the type parameters are exact should we create an
// ExactTypePattern for this WildTypePattern
if (typeParameters.areAllExact()) {
* If any of these checks fail, a warning message is issued and we return false.
* @return
*/
- private boolean verifyTypeParameters(ResolvedType baseType,IScope scope) {
+ private boolean verifyTypeParameters(ResolvedType baseType,IScope scope, boolean requireExactType) {
ResolvedType genericType = baseType.getGenericType();
if (genericType == null) {
// issue message "does not match because baseType.getName() is not generic"
(!foundEllipsis && minRequiredTypeParameters != tvs.length))
{
// issue message "does not match because wrong no of type params"
- scope.message(MessageUtil.warn(
- WeaverMessages.format(WeaverMessages.INCORRECT_NUMBER_OF_TYPE_ARGUMENTS,genericType.getName(),new Integer(tvs.length)),
- getSourceLocation()));
+ String msg = WeaverMessages.format(WeaverMessages.INCORRECT_NUMBER_OF_TYPE_ARGUMENTS,
+ genericType.getName(),new Integer(tvs.length));
+ if (requireExactType) scope.message(MessageUtil.error(msg,getSourceLocation()));
+ else scope.message(MessageUtil.warn(msg,getSourceLocation()));
return false;
}
// issue message that type parameter does not meet specification
String parameterName = ut.getName();
if (ut.isTypeVariableReference()) parameterName = ((TypeVariableReference)ut).getTypeVariable().getDisplayName();
- scope.message(MessageUtil.warn(
- WeaverMessages.format(
- WeaverMessages.VIOLATES_TYPE_VARIABLE_BOUNDS,
- parameterName,
- new Integer(i+1),
- tvs[i].getDisplayName(),
- genericType.getName()),
- getSourceLocation()));
+ String msg =
+ WeaverMessages.format(
+ WeaverMessages.VIOLATES_TYPE_VARIABLE_BOUNDS,
+ parameterName,
+ new Integer(i+1),
+ tvs[i].getDisplayName(),
+ genericType.getName());
+ if (requireExactType) scope.message(MessageUtil.error(msg,getSourceLocation()));
+ else scope.message(MessageUtil.warn(msg,getSourceLocation()));
return false;
}
}