Skip to content

Commit dfc5952

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Support for ConditionalExpression and AsExpression in constants.
Change-Id: I6816c884abe01876adf4d0189dabe93f1919487d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422323 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 760d7f2 commit dfc5952

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

pkg/analyzer/lib/src/fine/manifest_ast.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ class _ElementCollector extends ThrowingAstVisitor<void> {
168168
node.visitChildren(this);
169169
}
170170

171+
@override
172+
void visitAsExpression(AsExpression node) {
173+
node.visitChildren(this);
174+
}
175+
171176
@override
172177
void visitAssertInitializer(AssertInitializer node) {
173178
node.visitChildren(this);
@@ -182,6 +187,11 @@ class _ElementCollector extends ThrowingAstVisitor<void> {
182187
@override
183188
void visitBooleanLiteral(BooleanLiteral node) {}
184189

190+
@override
191+
void visitConditionalExpression(ConditionalExpression node) {
192+
node.visitChildren(this);
193+
}
194+
185195
@override
186196
void visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
187197
node.visitChildren(this);

pkg/analyzer/test/src/dart/analysis/driver_test.dart

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17087,6 +17087,42 @@ const e = '$b' 'x';
1708717087
);
1708817088
}
1708917089

17090+
test_manifest_constInitializer_asExpression() async {
17091+
await _runLibraryManifestScenario(
17092+
initialCode: r'''
17093+
const a = 0;
17094+
const b = 0;
17095+
const c = a as int;
17096+
const d = b as int;
17097+
''',
17098+
expectedInitialEvents: r'''
17099+
[operation] linkLibraryCycle SDK
17100+
[operation] linkLibraryCycle
17101+
package:test/test.dart
17102+
manifest
17103+
a: #M0
17104+
b: #M1
17105+
c: #M2
17106+
d: #M3
17107+
''',
17108+
updatedCode: r'''
17109+
const a = 0;
17110+
const b = 1;
17111+
const c = a as int;
17112+
const d = b as int;
17113+
''',
17114+
expectedUpdatedEvents: r'''
17115+
[operation] linkLibraryCycle
17116+
package:test/test.dart
17117+
manifest
17118+
a: #M0
17119+
b: #M4
17120+
c: #M2
17121+
d: #M5
17122+
''',
17123+
);
17124+
}
17125+
1709017126
test_manifest_constInitializer_binaryExpression() async {
1709117127
await _runLibraryManifestScenario(
1709217128
initialCode: r'''
@@ -17377,6 +17413,42 @@ const b = false;
1737717413
);
1737817414
}
1737917415

17416+
test_manifest_constInitializer_conditionalExpression() async {
17417+
await _runLibraryManifestScenario(
17418+
initialCode: r'''
17419+
const a = true;
17420+
const b = true;
17421+
const c = a ? 0 : 1;
17422+
const d = b ? 0 : 1;
17423+
''',
17424+
expectedInitialEvents: r'''
17425+
[operation] linkLibraryCycle SDK
17426+
[operation] linkLibraryCycle
17427+
package:test/test.dart
17428+
manifest
17429+
a: #M0
17430+
b: #M1
17431+
c: #M2
17432+
d: #M3
17433+
''',
17434+
updatedCode: r'''
17435+
const a = true;
17436+
const b = false;
17437+
const c = a ? 0 : 1;
17438+
const d = b ? 0 : 1;
17439+
''',
17440+
expectedUpdatedEvents: r'''
17441+
[operation] linkLibraryCycle
17442+
package:test/test.dart
17443+
manifest
17444+
a: #M0
17445+
b: #M4
17446+
c: #M2
17447+
d: #M5
17448+
''',
17449+
);
17450+
}
17451+
1738017452
test_manifest_constInitializer_constructorName_named() async {
1738117453
await _runLibraryManifestScenario(
1738217454
initialCode: r'''

0 commit comments

Comments
 (0)