Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 48383003: Support checking of malbounded types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 015402a3b49b7bc5a7b69fcfec5208f8db817a64..481aae6a0c9e9378bba0466f90e0188f0092e3e1 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -1779,7 +1779,7 @@ class TypeResolver {
addTypeVariableBoundsCheck) {
visitor.addDeferredAction(
visitor.enclosingElement,
- () => checkTypeVariableBounds(node, type));
+ () => checkTypeVariableBounds(visitor.mapping, node, type));
}
}
visitor.useType(node, type);
@@ -1787,26 +1787,23 @@ class TypeResolver {
}
/// Checks the type arguments of [type] against the type variable bounds.
- void checkTypeVariableBounds(TypeAnnotation node, GenericType type) {
- TypeDeclarationElement element = type.element;
- Link<DartType> typeArguments = type.typeArguments;
- Link<DartType> typeVariables = element.typeVariables;
- while (!typeVariables.isEmpty && !typeArguments.isEmpty) {
- TypeVariableType typeVariable = typeVariables.head;
- DartType bound = typeVariable.element.bound.subst(
- type.typeArguments, element.typeVariables);
- DartType typeArgument = typeArguments.head;
+ void checkTypeVariableBounds(TreeElements elements,
+ TypeAnnotation node, GenericType type) {
+ void checkTypeVariableBound(_, DartType typeArgument,
+ TypeVariableType typeVariable,
+ DartType bound) {
+ compiler.backend.registerTypeVariableBoundCheck(elements);
if (!compiler.types.isSubtype(typeArgument, bound)) {
compiler.reportWarningCode(node,
MessageKind.INVALID_TYPE_VARIABLE_BOUND,
{'typeVariable': typeVariable,
'bound': bound,
'typeArgument': typeArgument,
- 'thisType': element.thisType});
+ 'thisType': type.element.thisType});
}
- typeVariables = typeVariables.tail;
- typeArguments = typeArguments.tail;
- }
+ };
+
+ compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound);
}
/**

Powered by Google App Engine
This is Rietveld 408576698