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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart

Issue 2855323004: Infer VariableSet types. (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/kernel/kernel_shadow_ast.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
index 48a7845160516d20b6cb907503d7d3b92afba579..0b420a5cb1d704deb8ed169bc3ba7bef6ef076a8 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
@@ -884,3 +884,27 @@ class KernelVariableGet extends VariableGet implements KernelExpression {
});
}
}
+
+/// Concrete shadow object representing a write to a variable in kernel form.
+class KernelVariableSet extends VariableSet implements KernelExpression {
+ KernelVariableSet(VariableDeclaration variable, Expression value)
+ : super(variable, value);
+
+ @override
+ DartType _inferExpression(
+ KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
+ DartType declaredType;
+ var variable = this.variable;
+ if (variable is KernelVariableDeclaration) {
+ declaredType = variable._declaredType;
+ } else {
+ // Hack to deal with the fact that BodyBuilder still creates raw
+ // VariableDeclaration objects sometimes.
+ // TODO(paulberry): get rid of this once the type parameter is
+ // KernelVariableDeclaration.
+ declaredType = variable.type;
+ }
+ // TODO(scheglov) Should we use the declared type, or the promoted type?
Paul Berry 2017/05/04 19:31:03 I believe the declared type is better, since the p
scheglov 2017/05/04 19:41:01 Acknowledged.
+ return inferrer.inferVariableSet(typeNeeded, declaredType, value);
scheglov 2017/05/04 18:41:58 We don't need "typeContext" in inferrer, should we
Paul Berry 2017/05/04 19:31:03 I would prefer for us to pass it in for consistenc
scheglov 2017/05/04 19:41:01 Done.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698