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

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

Issue 2039833002: New tests for initializing formal access. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Review response, just changing expected exception type 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 | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/dart_messages/lib/shared_messages.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/typechecker.dart
diff --git a/pkg/compiler/lib/src/typechecker.dart b/pkg/compiler/lib/src/typechecker.dart
index 85710b11d3da5cbf9d040e3dd29402925f1cfc42..b7fa5de07f72431bfc5fe075cc7694276c91329e 100644
--- a/pkg/compiler/lib/src/typechecker.dart
+++ b/pkg/compiler/lib/src/typechecker.dart
@@ -681,7 +681,12 @@ class TypeCheckerVisitor extends Visitor<DartType> {
assert(invariant(node, element != null,
message: 'Missing element for identifier'));
assert(invariant(
- node, element.isVariable || element.isParameter || element.isField,
+ node,
+ element.isVariable ||
+ element.isParameter ||
+ element.isField ||
+ (element.isInitializingFormal &&
+ compiler.options.enableInitializingFormalAccess),
message: 'Unexpected context element ${element}'));
return element.computeType(resolution);
}
@@ -762,7 +767,9 @@ class TypeCheckerVisitor extends Visitor<DartType> {
return access;
}
if (receiverElement != null &&
- (receiverElement.isVariable || receiverElement.isParameter)) {
+ (receiverElement.isVariable || receiverElement.isParameter ||
+ (receiverElement.isInitializingFormal &&
+ compiler.options.enableInitializingFormalAccess))) {
Link<TypePromotion> typePromotions = typePromotionsMap[receiverElement];
if (typePromotions != null) {
while (!typePromotions.isEmpty) {
@@ -1078,7 +1085,9 @@ class TypeCheckerVisitor extends Visitor<DartType> {
}
ElementAccess createPromotedAccess(Element element) {
- if (element.isVariable || element.isParameter) {
+ if (element.isVariable || element.isParameter ||
+ (element.isInitializingFormal &&
+ compiler.options.enableInitializingFormalAccess)) {
TypePromotion typePromotion = getKnownTypePromotion(element);
if (typePromotion != null) {
return new PromotedAccess(element, typePromotion.type);
@@ -1213,7 +1222,11 @@ class TypeCheckerVisitor extends Visitor<DartType> {
}
}
- if (variable != null && (variable.isVariable || variable.isParameter)) {
+ if (variable != null &&
+ (variable.isVariable ||
+ variable.isParameter ||
+ (variable.isInitializingFormal &&
+ compiler.options.enableInitializingFormalAccess))) {
DartType knownType = getKnownType(variable);
if (!knownType.isDynamic) {
DartType shownType = elements.getType(node.arguments.head);
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/dart_messages/lib/shared_messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698