Only track type promotion of locals
Change-Id: Ib576bc70128a5b0b045d5083f06a19e822c302b4
Reviewed-on: https://dart-review.googlesource.com/c/84026
Commit-Queue: Peter von der Ahé <ahe@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Auto-Submit: Peter von der Ahé <ahe@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
diff --git a/pkg/front_end/lib/src/fasta/source/type_promotion_look_ahead_listener.dart b/pkg/front_end/lib/src/fasta/source/type_promotion_look_ahead_listener.dart
index a5075bc..3b60139 100644
--- a/pkg/front_end/lib/src/fasta/source/type_promotion_look_ahead_listener.dart
+++ b/pkg/front_end/lib/src/fasta/source/type_promotion_look_ahead_listener.dart
@@ -643,11 +643,16 @@
@override
void handleIdentifier(Token token, IdentifierContext context) {
- debugEvent("Identifier", token);
+ debugEvent("Identifier ${context}", token);
if (context.inSymbol) {
// Do nothing.
} else if (context.inDeclaration) {
- state.declareIdentifier(token);
+ if (identical(IdentifierContext.localVariableDeclaration, context) ||
+ identical(IdentifierContext.formalParameterDeclaration, context)) {
+ state.declareIdentifier(token);
+ } else {
+ state.pushNull(token.lexeme, token);
+ }
} else if (context.isContinuation) {
state.pushNull(token.lexeme, token);
} else if (context.isScopeReference) {