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

Unified Diff: pkg/analyzer/lib/dart/element/type.dart

Issue 1609093003: fixes #25482, flatten Futures in strong mode so Future.then works (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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: pkg/analyzer/lib/dart/element/type.dart
diff --git a/pkg/analyzer/lib/dart/element/type.dart b/pkg/analyzer/lib/dart/element/type.dart
index 548dc1d4e64c7a350e948f4f65211ccadb9a8b73..5b92819fd23e6cbc89f8097b2efe35016677e537 100644
--- a/pkg/analyzer/lib/dart/element/type.dart
+++ b/pkg/analyzer/lib/dart/element/type.dart
@@ -6,6 +6,7 @@ library analyzer.dart.element.type;
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart' show InterfaceTypeImpl;
+import 'package:analyzer/src/generated/type_system.dart' show TypeSystem;
/**
* The type associated with elements in the element model.
@@ -38,6 +39,12 @@ abstract class DartType {
bool get isBottom;
/**
+ * Return `true` if this type represents the type 'Future' defined in the
+ * dart:async library.
+ */
+ bool get isDartAsyncFuture;
+
+ /**
* Return `true` if this type represents the type 'Function' defined in the
* dart:core library.
*/
@@ -70,6 +77,19 @@ abstract class DartType {
String get name;
/**
+ * Implements the function "flatten" defined in the spec, where T is this
+ * type:
+ *
+ * If T = Future<S> then flatten(T) = flatten(S).
+ *
+ * Otherwise if T <: Future then let S be a type such that T << Future<S>
+ * and for all R, if T << Future<R> then S << R. Then flatten(T) = S.
+ *
+ * In any other circumstance, flatten(T) = T.
+ */
+ DartType flattenFutures(TypeSystem typeSystem);
vsm 2016/01/21 19:17:46 Might be cleaner to move this to TypeSystem. It's
Jennifer Messerly 2016/01/21 19:31:38 Brian, what do you think? I actually went back an
Brian Wilkerson 2016/01/21 20:20:57 Personally, I'd say to leave it as is for now. The
+
+ /**
* Return `true` if this type is assignable to the given [type]. A type
* <i>T</i> may be assigned to a type <i>S</i>, written <i>T</i> &hArr;
* <i>S</i>, iff either <i>T</i> <: <i>S</i> or <i>S</i> <: <i>T</i>.
@@ -137,16 +157,6 @@ abstract class FunctionType implements ParameterizedType {
List<TypeParameterElement> get boundTypeParameters;
/**
- * The formal type parameters of this generic function.
- * For example `<T> T -> T`.
- *
- * These are distinct from the [typeParameters] list, which contains type
- * parameters from surrounding contexts, and thus are free type variables from
- * the perspective of this function type.
- */
- List<TypeParameterElement> get typeFormals;
-
- /**
* Return a map from the names of named parameters to the types of the named
* parameters of this type of function. The entries in the map will be
* iterated in the same order as the order in which the named parameters were
@@ -184,6 +194,16 @@ abstract class FunctionType implements ParameterizedType {
DartType get returnType;
/**
+ * The formal type parameters of this generic function.
+ * For example `<T> T -> T`.
+ *
+ * These are distinct from the [typeParameters] list, which contains type
+ * parameters from surrounding contexts, and thus are free type variables from
+ * the perspective of this function type.
+ */
+ List<TypeParameterElement> get typeFormals;
+
+ /**
* Return the type resulting from instantiating (replacing) the given
* [argumentTypes] for this function's bound type parameters.
*/

Powered by Google App Engine
This is Rietveld 408576698