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

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

Issue 2013093002: Summarize references to closure parameters properly. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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 955d67777218263feb394df4f5b04418decb114c..d50f60dfa65d98d01b35fdba61b7a62325bf9d7f 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -1756,8 +1756,7 @@ class C {
}
''');
_assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression,
- operators: [UnlinkedConstOperation.pushConstructorParameter],
- strings: ['a']);
+ operators: [UnlinkedConstOperation.pushParameter], strings: ['a']);
}
test_constExpr_constructorParam_shadows_typeParam() {
@@ -1768,8 +1767,7 @@ class C<T> {
}
''');
_assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression,
- operators: [UnlinkedConstOperation.pushConstructorParameter],
- strings: ['T']);
+ operators: [UnlinkedConstOperation.pushParameter], strings: ['T']);
}
test_constExpr_functionExpression_asArgument() {
@@ -3462,8 +3460,7 @@ class C {
expect(initializer.kind, UnlinkedConstructorInitializerKind.field);
expect(initializer.name, 'x');
_assertUnlinkedConst(initializer.expression,
- operators: [UnlinkedConstOperation.pushConstructorParameter],
- strings: ['p']);
+ operators: [UnlinkedConstOperation.pushParameter], strings: ['p']);
expect(initializer.arguments, isEmpty);
}
@@ -7083,6 +7080,54 @@ final v = ((a, b) => 42)(1, 2);
expect(variable.initializer.localFunctions[0].bodyExpr, isNull);
}
+ test_expr_inClosure_refersToOuterParam() {
+ if (skipNonConstInitializers) {
+ return;
+ }
+ UnlinkedVariable variable =
+ serializeVariableText('var v = (x) => (y) => x;');
+ _assertUnlinkedConst(
+ variable.initializer.localFunctions[0].localFunctions[0].bodyExpr,
+ operators: [UnlinkedConstOperation.pushParameter],
+ strings: ['x']);
+ }
+
+ test_expr_inClosure_refersToParam() {
+ if (skipNonConstInitializers) {
+ return;
+ }
+ UnlinkedVariable variable = serializeVariableText('var v = (x) => x;');
+ _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr,
+ operators: [UnlinkedConstOperation.pushParameter], strings: ['x']);
+ }
+
+ test_expr_inClosure_refersToParam_outOfScope() {
+ if (skipNonConstInitializers) {
+ return;
+ }
+ UnlinkedVariable variable =
+ serializeVariableText('var x; var v = (b) => (b ? (x) => x : x);');
+ _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr,
+ isValidConst: false,
+ operators: [
+ UnlinkedConstOperation.pushParameter,
+ UnlinkedConstOperation.pushLocalFunctionReference,
+ UnlinkedConstOperation.pushReference,
+ UnlinkedConstOperation.conditional,
+ ],
+ strings: [
+ 'b'
+ ],
+ ints: [
+ 0,
+ 0
+ ],
+ referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'x',
+ expectedKind: ReferenceKind.topLevelPropertyAccessor)
+ ]);
+ }
+
test_expr_invokeMethod_instance() {
if (skipNonConstInitializers) {
return;

Powered by Google App Engine
This is Rietveld 408576698