-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of modified scoping for initializing formals.
In order to make an implementation of initializing formal access in `dart2js` available as specified in issue #26655 now, this CL changes the scope management such that initializing formals are not in scope in the constructor body, only in the initializer list. This is done by introducing a new notion of scopes implemented by `ExtensionScope`: Such a scope will extend an existing `NestedScope` rather than adding a new nested scope to it. R=johnniwinther@google.com Review URL: https://codereview.chromium.org/2059883002 .
- Loading branch information
Showing
9 changed files
with
135 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// DartOptions=--initializing-formal-access | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
// Duplicate definition checks for `this.x` will check the scopes associated | ||
// with the constructor, not all enclosing scopes; so this is not a conflict. | ||
var x; | ||
|
||
class A { | ||
var x; | ||
A(this.x) { | ||
// In the body the field is in scope, not the initializing formal; | ||
// so we can use the setter. | ||
x += 1; | ||
} | ||
} | ||
|
||
main() { | ||
A a = new A(2); | ||
Expect.equals(a.x, 3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters