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

Unified Diff: pkg/compiler/lib/src/resolution/resolution.dart

Issue 2059883002: Implementation of modified scoping for initializing formals. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | tests/language/initializing_formal_scope_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/resolution.dart
diff --git a/pkg/compiler/lib/src/resolution/resolution.dart b/pkg/compiler/lib/src/resolution/resolution.dart
index f1ca6d02630b1314b5480dbdf9430ed0556a8a0b..81848d267bc65dfa7226af6bc5b575c1d1b3e17c 100644
--- a/pkg/compiler/lib/src/resolution/resolution.dart
+++ b/pkg/compiler/lib/src/resolution/resolution.dart
@@ -53,6 +53,7 @@ import 'class_members.dart' show MembersCreator;
import 'constructors.dart';
import 'members.dart';
import 'registry.dart';
+import 'scope.dart' show MutableScope;
import 'signatures.dart';
import 'tree_elements.dart';
import 'typedefs.dart';
@@ -248,6 +249,22 @@ class ResolverTask extends CompilerTask {
if (redirection != null) {
resolveRedirectingConstructor(resolver, tree, element, redirection);
}
+ if (compiler.options.enableInitializingFormalAccess) {
Johnni Winther 2016/06/13 08:56:48 There is a better approach: 1. Create a subscope
eernst 2016/06/14 15:01:51 That sounds like a much better idea, but there are
+ // Ensure that the initializing formal parameters will not be in scope
+ // when the body of the constructor is resolved.
+ // TODO(eernst): The following is a temporary solution. An acceptable
+ // solution requires some more thinking & refactoring: We don't
+ // otherwise delete from scopes, it introduces ordering dependencies,
+ // etc.etc.etc.
+ assert(visitor.scope is MutableScope);
+ MutableScope mutableScope = visitor.scope;
+ List<String> names = mutableScope.elements.keys.toList();
+ for (String name in names) {
+ if (mutableScope.elements[name] is InitializingFormalElement) {
+ mutableScope.elements.remove(name);
+ }
+ }
+ }
} else if (tree.initializers != null) {
reporter.reportErrorMessage(
tree, MessageKind.FUNCTION_WITH_INITIALIZER);
« no previous file with comments | « no previous file | tests/language/initializing_formal_scope_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698