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

Unified Diff: pkg/compiler/lib/src/elements/resolution_types.dart

Issue 2918913003: Handle list and map literals (Closed)
Patch Set: Updated cf. comments Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/elements/types.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/elements/resolution_types.dart
diff --git a/pkg/compiler/lib/src/elements/resolution_types.dart b/pkg/compiler/lib/src/elements/resolution_types.dart
index 7631c80fa59ffd2130f79df4370f09a984edb450..cc309c1c568a0153a4f331c1c58177ae15431075 100644
--- a/pkg/compiler/lib/src/elements/resolution_types.dart
+++ b/pkg/compiler/lib/src/elements/resolution_types.dart
@@ -1070,13 +1070,10 @@ class ResolutionPotentialSubtypeVisitor extends PotentialSubtypeVisitor
* substitute for the bound of [typeVariable]. [bound] holds the bound against
* which [typeArgument] should be checked.
*/
-typedef void CheckTypeVariableBound(
- GenericType type,
- ResolutionDartType typeArgument,
- ResolutionTypeVariableType typeVariable,
- ResolutionDartType bound);
+typedef void CheckTypeVariableBound<T extends GenericType>(T type,
+ DartType typeArgument, TypeVariableType typeVariable, DartType bound);
-class Types implements DartTypes {
+class Types extends DartTypes {
final Resolution resolution;
final ResolutionMoreSpecificVisitor moreSpecificVisitor;
final ResolutionSubtypeVisitor subtypeVisitor;
@@ -1104,6 +1101,17 @@ class Types implements DartTypes {
}
@override
+ ResolutionDartType substByContext(
+ ResolutionDartType base, ResolutionInterfaceType context) {
+ return base.substByContext(context);
+ }
+
+ @override
+ InterfaceType getThisType(ClassElement cls) {
+ return cls.thisType;
+ }
+
+ @override
ResolutionInterfaceType getSupertype(ClassElement cls) {
return cls.supertype;
}
@@ -1177,29 +1185,27 @@ class Types implements DartTypes {
return subtypeVisitor.isAssignable(r, s);
}
- static const int IS_SUBTYPE = 1;
- static const int MAYBE_SUBTYPE = 0;
- static const int NOT_SUBTYPE = -1;
-
- int computeSubtypeRelation(ResolutionDartType t, ResolutionDartType s) {
- // TODO(johnniwinther): Compute this directly in [isPotentialSubtype].
- if (isSubtype(t, s)) return IS_SUBTYPE;
- return isPotentialSubtype(t, s) ? MAYBE_SUBTYPE : NOT_SUBTYPE;
- }
-
bool isPotentialSubtype(ResolutionDartType t, ResolutionDartType s) {
// TODO(johnniwinther): Return a set of variable points in the positive
// cases.
return potentialSubtypeVisitor.isSubtype(t, s);
}
+ @override
+ void checkTypeVariableBounds(
+ ResolutionInterfaceType type,
+ void checkTypeVariableBound(InterfaceType type, DartType typeArgument,
+ TypeVariableType typeVariable, DartType bound)) {
+ genericCheckTypeVariableBounds(type, checkTypeVariableBound);
+ }
+
/**
* Checks the type arguments of [type] against the type variable bounds
* declared on [element]. Calls [checkTypeVariableBound] on each type
* argument and bound.
*/
- void checkTypeVariableBounds(
- GenericType type, CheckTypeVariableBound checkTypeVariableBound) {
+ void genericCheckTypeVariableBounds<T extends GenericType>(
+ T type, CheckTypeVariableBound<T> checkTypeVariableBound) {
TypeDeclarationElement element = type.element;
List<ResolutionDartType> typeArguments = type.typeArguments;
List<ResolutionDartType> typeVariables = element.typeVariables;
@@ -1236,27 +1242,6 @@ class Types implements DartTypes {
}
/**
- * Returns the [ClassElement] which declares the type variables occurring in
- * [type], or [:null:] if [type] does not contain type variables.
- */
- static ClassEntity getClassContext(DartType type) {
- ClassEntity contextClass;
- type.forEachTypeVariable((TypeVariableType typeVariable) {
- if (typeVariable.element.typeDeclaration is! ClassEntity) return;
- contextClass = typeVariable.element.typeDeclaration;
- });
- // GENERIC_METHODS: When generic method support is complete enough to
- // include a runtime value for method type variables this must be updated.
- // For full support the global assumption that all type variables are
- // declared by the same enclosing class will not hold: Both an enclosing
- // method and an enclosing class may define type variables, so the return
- // type cannot be [ClassElement] and the caller must be prepared to look in
- // two locations, not one. Currently we ignore method type variables by
- // returning in the next statement.
- return contextClass;
- }
-
- /**
* A `compareTo` function that globally orders types using
* [Elements.compareByPosition] to order types defined by a declaration.
*
« no previous file with comments | « no previous file | pkg/compiler/lib/src/elements/types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698