| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
|
| diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
|
| index 8aa3df06ee066c587da1ad3bedd84c64030a11cf..107e6c8e6d4b2978f7242383f6c87757385091f8 100644
|
| --- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
|
| +++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
|
| @@ -934,6 +934,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| checkForBuiltInIdentifierAsName(
|
| node.getName(),
|
| CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME);
|
| + checkForTypeParameterSupertypeOfItsBound(node);
|
| return super.visitTypeParameter(node);
|
| }
|
|
|
| @@ -4584,6 +4585,32 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| }
|
|
|
| /**
|
| + * This checks that if the passed type parameter is a supertype of its bound.
|
| + *
|
| + * @param node the type parameter to evaluate
|
| + * @return {@code true} if and only if an error code is generated on the passed node
|
| + * @see StaticTypeWarningCode#TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND
|
| + */
|
| + private boolean checkForTypeParameterSupertypeOfItsBound(TypeParameter node) {
|
| + TypeParameterElement element = node.getElement();
|
| + // prepare bound
|
| + Type bound = element.getBound();
|
| + if (bound == null) {
|
| + return false;
|
| + }
|
| + // OK, type parameter is not supertype of its bound
|
| + if (!bound.isMoreSpecificThan(element.getType())) {
|
| + return false;
|
| + }
|
| + // report problem
|
| + errorReporter.reportError(
|
| + StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND,
|
| + node,
|
| + element.getDisplayName());
|
| + return true;
|
| + }
|
| +
|
| + /**
|
| * This checks that if the passed generative constructor has neither an explicit super constructor
|
| * invocation nor a redirecting constructor invocation, that the superclass has a default
|
| * generative constructor.
|
|
|