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

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart

Issue 2904263003: Implement type inference for await expressions in front_end. (Closed)
Patch Set: 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
Index: pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
index 16beabb7bf8e4b37d3da6afa9aebed4077fb3836..1c1b7a20dacb1d5a76a885ed0afa45fc46347903 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
@@ -36,13 +36,13 @@ class TypeConstraint {
}
class TypeSchemaEnvironment extends TypeEnvironment {
+ @override
+ final bool strongMode;
+
TypeSchemaEnvironment(
CoreTypes coreTypes, ClassHierarchy hierarchy, this.strongMode)
: super(coreTypes, hierarchy);
- @override
- final bool strongMode;
-
/// Modify the given [constraint]'s lower bound to include [lower].
void addLowerBound(TypeConstraint constraint, DartType lower) {
constraint.lower = getLeastUpperBound(constraint.lower, lower);
@@ -226,13 +226,6 @@ class TypeSchemaEnvironment extends TypeEnvironment {
List<DartType> actualTypes,
DartType returnContextType,
List<DartType> inferredTypes) {
- if (returnContextType is DynamicType) {
- // Analyzer treats a type context of `dynamic` as equivalent to an empty
- // context. TODO(paulberry): this is not spec'ed anywhere; do we still
- // want to do this?
- returnContextType = null;
- }
-
if (typeParametersToInfer.isEmpty) {
return;
}
@@ -243,7 +236,7 @@ class TypeSchemaEnvironment extends TypeEnvironment {
// are implied by this.
var gatherer = new TypeConstraintGatherer(this, typeParametersToInfer);
- if (returnContextType != null) {
+ if (!isEmptyContext(returnContextType)) {
gatherer.trySubtypeMatch(declaredReturnType, returnContextType);
}
@@ -396,6 +389,16 @@ class TypeSchemaEnvironment extends TypeEnvironment {
}
}
+ bool isEmptyContext(DartType context) {
+ if (context is DynamicType) {
+ // Analyzer treats a type context of `dynamic` as equivalent to an empty
+ // context. TODO(paulberry): this is not spec'ed anywhere; do we still
+ // want to do this?
+ return true;
+ }
+ return context == null;
+ }
+
@override
bool isTop(DartType t) {
if (t is UnknownType) {
« no previous file with comments | « pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart ('k') | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698