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

Unified Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1673373002: Test some corner cases of shadowing between scopes when summarizing constants. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index cd0e2ee1d2b9f859327e8ffebf5d619553ca9d10..63009b8442905c7c0b25c1587772de0ff1430a44 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -1540,6 +1540,33 @@ class E {}
]);
}
+ test_constExpr_classMember_shadows_typeParam() {
+ // Although it is an error for a class member to have the same name as a
+ // type parameter, the spec makes it clear that the class member scope is
+ // nested inside the type parameter scope. So go ahead and verify that
+ // the class member shadows the type parameter.
+ String text = '''
+class C<T> {
+ static const T = null;
+ final x;
+ const C() : x = T;
+}
+''';
+ UnlinkedClass cls = serializeClassText(text, allowErrors: true);
+ _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression,
+ operators: [
+ UnlinkedConstOperation.pushReference
+ ],
+ referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'T',
+ expectedKind: ReferenceKind.propertyAccessor,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
+ numTypeParameters: 1)
+ ])
+ ]);
+ }
+
test_constExpr_conditional() {
UnlinkedVariable variable =
serializeVariableText('const v = true ? 1 : 2;', allowErrors: true);
@@ -1554,6 +1581,31 @@ class E {}
]);
}
+ test_constExpr_constructorParam_shadows_classMember() {
+ UnlinkedClass cls = serializeClassText('''
+class C {
+ static const a = null;
+ final b;
+ const C(a) : b = a;
+}
+''');
+ _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression,
+ operators: [UnlinkedConstOperation.pushConstructorParameter],
+ strings: ['a']);
+ }
+
+ test_constExpr_constructorParam_shadows_typeParam() {
+ UnlinkedClass cls = serializeClassText('''
+class C<T> {
+ final x;
+ const C(T) : x = T;
+}
+''');
+ _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression,
+ operators: [UnlinkedConstOperation.pushConstructorParameter],
+ strings: ['T']);
+ }
+
test_constExpr_identical() {
UnlinkedVariable variable =
serializeVariableText('const v = identical(42, null);');
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698