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

Unified Diff: pkg/analyzer/lib/src/generated/type_system.dart

Issue 2539243002: Transition analyzer and analysis_server to new astFactory; remove old AST factory methods. (Closed)
Patch Set: Update CHANGELOG Created 4 years 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: pkg/analyzer/lib/src/generated/type_system.dart
diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
index 2f4229625823b42dd4f5c686ce762785c015c21c..5f0d96dc24a860984a28e1daaf5202fed40a2282 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -171,32 +171,6 @@ class StrongTypeSystemImpl extends TypeSystem {
}
@override
- DartType tryPromoteToType(DartType to, DartType from) {
- // Allow promoting to a subtype, for example:
- //
- // f(Base b) {
- // if (b is SubTypeOfBase) {
- // // promote `b` to SubTypeOfBase for this block
- // }
- // }
- //
- // This allows the variable to be used wherever the supertype (here `Base`)
- // is expected, while gaining a more precise type.
- if (isSubtypeOf(to, from)) {
- return to;
- }
- // For a type parameter `T extends U`, allow promoting the upper bound
- // `U` to `S` where `S <: U`, yielding a type parameter `T extends S`.
- if (from is TypeParameterType) {
- if (isSubtypeOf(to, from.resolveToBound(DynamicTypeImpl.instance))) {
- return new TypeParameterMember(from.element, null, to).type;
- }
- }
-
- return null;
- }
-
- @override
FunctionType functionTypeToConcreteType(
TypeProvider typeProvider, FunctionType t) {
// TODO(jmesserly): should we use a real "fuzzyArrow" bit on the function
@@ -610,6 +584,32 @@ class StrongTypeSystemImpl extends TypeSystem {
}
@override
+ DartType tryPromoteToType(DartType to, DartType from) {
Brian Wilkerson 2016/11/30 20:05:31 This appears to just be sorting changes. Let me kn
Paul Berry 2016/11/30 20:21:57 Whoops, you are correct. Reverted this file to av
+ // Allow promoting to a subtype, for example:
+ //
+ // f(Base b) {
+ // if (b is SubTypeOfBase) {
+ // // promote `b` to SubTypeOfBase for this block
+ // }
+ // }
+ //
+ // This allows the variable to be used wherever the supertype (here `Base`)
+ // is expected, while gaining a more precise type.
+ if (isSubtypeOf(to, from)) {
+ return to;
+ }
+ // For a type parameter `T extends U`, allow promoting the upper bound
+ // `U` to `S` where `S <: U`, yielding a type parameter `T extends S`.
+ if (from is TypeParameterType) {
+ if (isSubtypeOf(to, from.resolveToBound(DynamicTypeImpl.instance))) {
+ return new TypeParameterMember(from.element, null, to).type;
+ }
+ }
+
+ return null;
+ }
+
+ @override
DartType typeToConcreteType(TypeProvider typeProvider, DartType t) {
if (t is FunctionType) {
return functionTypeToConcreteType(typeProvider, t);
@@ -1046,20 +1046,6 @@ class StrongTypeSystemImpl extends TypeSystem {
*/
abstract class TypeSystem {
/**
- * Tries to promote from the first type from the second type, and returns the
- * promoted type if it succeeds, otherwise null.
- *
- * In the Dart 1 type system, it is not possible to promote from or to
- * `dynamic`, and we must be promoting to a more specific type, see
- * [isMoreSpecificThan]. Also it will always return the promote [to] type or
- * null.
- *
- * In strong mode, this can potentially return a different type, see
- * the override in [StrongTypeSystemImpl].
- */
- DartType tryPromoteToType(DartType to, DartType from);
-
- /**
* Make a function type concrete.
*
* Normally we treat dynamically typed parameters as bottom for function
@@ -1272,6 +1258,20 @@ abstract class TypeSystem {
}
/**
+ * Tries to promote from the first type from the second type, and returns the
+ * promoted type if it succeeds, otherwise null.
+ *
+ * In the Dart 1 type system, it is not possible to promote from or to
+ * `dynamic`, and we must be promoting to a more specific type, see
+ * [isMoreSpecificThan]. Also it will always return the promote [to] type or
+ * null.
+ *
+ * In strong mode, this can potentially return a different type, see
+ * the override in [StrongTypeSystemImpl].
+ */
+ DartType tryPromoteToType(DartType to, DartType from);
+
+ /**
* Given a [DartType] type, return the [TypeParameterElement]s corresponding
* to its formal type parameters (if any).
*
@@ -1423,18 +1423,6 @@ class TypeSystemImpl extends TypeSystem {
TypeSystemImpl();
@override
- DartType tryPromoteToType(DartType to, DartType from) {
- // Declared type should not be "dynamic".
- // Promoted type should not be "dynamic".
- // Promoted type should be more specific than declared.
- if (!from.isDynamic && !to.isDynamic && to.isMoreSpecificThan(from)) {
- return to;
- } else {
- return null;
- }
- }
-
- @override
FunctionType functionTypeToConcreteType(
TypeProvider typeProvider, FunctionType t) =>
t;
@@ -1469,6 +1457,18 @@ class TypeSystemImpl extends TypeSystem {
}
@override
+ DartType tryPromoteToType(DartType to, DartType from) {
+ // Declared type should not be "dynamic".
+ // Promoted type should not be "dynamic".
+ // Promoted type should be more specific than declared.
+ if (!from.isDynamic && !to.isDynamic && to.isMoreSpecificThan(from)) {
+ return to;
+ } else {
+ return null;
+ }
+ }
+
+ @override
DartType typeToConcreteType(TypeProvider typeProvider, DartType t) => t;
@override

Powered by Google App Engine
This is Rietveld 408576698