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

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

Issue 2933643002: Implement type inference for assignments to a static variable. (Closed)
Patch Set: Created 3 years, 6 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 67eaee84965d0afdd4aafb97d012d3e93e9d3ff0..8c96d393783ad53ba4043da27a4b8a9d02cef848 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
@@ -1449,6 +1449,28 @@ abstract class KernelStatement extends Statement {
void _inferStatement(KernelTypeInferrer inferrer);
}
+/// Concrete shadow object representing an assignment to a static variable.
+class KernelStaticAssignment extends KernelComplexAssignment {
+ KernelStaticAssignment(Expression rhs) : super(rhs);
+
+ @override
+ DartType _inferExpression(
+ KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
+ typeNeeded = inferrer.listener.staticAssignEnter(desugared, typeContext) ||
+ typeNeeded;
+ // TODO(paulberry): record the appropriate types on let variables and
+ // conditional expressions.
+ DartType writeContext;
+ var write = this.write;
+ if (write is StaticSet) {
+ writeContext = write.target.setterType;
+ }
+ var inferredType = _inferRhs(inferrer, writeContext);
+ inferrer.listener.staticAssignExit(desugared, inferredType);
+ return inferredType;
+ }
+}
+
/// Concrete shadow object representing a read of a static variable in kernel
/// form.
class KernelStaticGet extends StaticGet implements KernelExpression {

Powered by Google App Engine
This is Rietveld 408576698