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

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

Issue 2849293002: Infer types of bool/null/string literals. (Closed)
Patch Set: Created 3 years, 8 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_inferrer.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index ff133dd3939abdd2f2067b2618bb960c3754b9f8..28edb199bae95470d92d03f9e014c097176e8bdc 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -78,6 +78,14 @@ abstract class TypeInferrerImpl<S, E, V, F> extends TypeInferrer<S, E, V, F> {
/// initializer.
E getFieldInitializer(F field);
+ /// Performs the core type inference algorithm for boolean literals.
+ ///
+ /// [typeContext], [typeNeeded], and the return value behave as described in
+ /// [inferExpression].
+ DartType inferBoolLiteral(DartType typeContext, bool typeNeeded) {
+ return typeNeeded ? coreTypes.boolClass.rawType : null;
+ }
+
/// Performs the core type inference algorithm for double literals.
///
/// [typeContext], [typeNeeded], and the return value behave as described in
@@ -201,6 +209,14 @@ abstract class TypeInferrerImpl<S, E, V, F> extends TypeInferrer<S, E, V, F> {
return typeNeeded ? getterType : null;
}
+ /// Performs the core type inference algorithm for string literals.
+ ///
+ /// [typeContext], [typeNeeded], and the return value behave as described in
+ /// [inferExpression].
+ DartType inferStringLiteral(DartType typeContext, bool typeNeeded) {
+ return typeNeeded ? coreTypes.stringClass.rawType : null;
+ }
+
/// Performs the core type inference algorithm for variable declarations.
///
/// [declaredType] is the declared type of the variable, or `null` if the type

Powered by Google App Engine
This is Rietveld 408576698