Skip to content

Commit a0aae8d

Browse files
scheglovCommit Queue
authored andcommitted
---
yaml --- r: 361479 b: refs/heads/main c: 7de6c03 h: refs/heads/main i: 361477: ffc5ebc 361475: 65c4766 361471: 8e858a6
1 parent 00e3685 commit a0aae8d

File tree

5 files changed

+64
-5
lines changed

5 files changed

+64
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ refs/tags/2.14.0-96.0.dev: 1eee24e50fc3028754d9a8e98852b949c04da4e4
19881988
refs/tags/2.14.0-97.0.dev: ba9c1636e87fbdcc02b8bc4a584455c32f8378b4
19891989
refs/tags/2.14.0-98.0.dev: f2d370c93582bbf4da42b5dd4c906d6145b01ea9
19901990
refs/tags/2.14.0-99.0.dev: e722f62b48fb382534efc1f20735def68848006f
1991-
refs/heads/main: 641110ec3800fcba28cdb747d44260af52190c47
1991+
refs/heads/main: 7de6c03e5758bf778912c2f96352be35fc9b045c
19921992
refs/heads/TedSander-patch-1: 739563c962fea6f5e2883a8d84f8638c48f2aa40
19931993
refs/tags/2.13.1: 53a67a7b0650edb435535a50b5c430abbc68bc60
19941994
refs/tags/2.13.3: a77223333944631f8f48a76e7f4697a4877e29d7

trunk/pkg/analyzer/lib/src/dart/ast/utilities.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,15 @@ class NodeReplacer extends ThrowingAstVisitor<bool> {
22462246
return visitNode(node);
22472247
}
22482248

2249+
@override
2250+
bool visitConstantPattern(covariant ConstantPatternImpl node) {
2251+
if (identical(node.expression, _oldNode)) {
2252+
node.expression = _newNode as ExpressionImpl;
2253+
return true;
2254+
}
2255+
return visitNode(node);
2256+
}
2257+
22492258
@override
22502259
bool visitConstructorDeclaration(covariant ConstructorDeclarationImpl node) {
22512260
if (identical(node.returnType, _oldNode)) {

trunk/pkg/analyzer/test/generated/utilities_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,22 @@ void f() {
517517
);
518518
}
519519

520+
void test_constantPattern() {
521+
var findNode = _parseStringToFindNode(r'''
522+
void f(x) async {
523+
if (x case 0) {}
524+
if (x case 1) {}
525+
}
526+
''');
527+
_assertReplacementForChildren<ConstantPattern>(
528+
destination: findNode.caseClause('0').pattern as ConstantPattern,
529+
source: findNode.caseClause('1').pattern as ConstantPattern,
530+
childAccessors: [
531+
(node) => node.expression,
532+
],
533+
);
534+
}
535+
520536
void test_constructorDeclaration() {
521537
var findNode = _parseStringToFindNode(r'''
522538
class A {

trunk/pkg/analyzer/test/src/dart/resolution/cast_pattern_test.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@ void f(x) {
2121
}
2222
''');
2323
final node = findNode.caseClause('case').pattern;
24-
assertParsedNodeText(node, r'''
24+
assertResolvedNodeText(node, r'''
2525
CastPattern
2626
pattern: VariablePattern
2727
keyword: var
2828
name: y
29+
declaredElement: hasImplicitType y@29
30+
type: int
2931
asToken: as
3032
type: NamedType
3133
name: SimpleIdentifier
3234
token: int
35+
staticElement: dart:core::@class::int
36+
staticType: null
37+
type: int
3338
''');
3439
}
3540

@@ -43,15 +48,20 @@ void f(x, y) {
4348
}
4449
''');
4550
final node = findNode.switchPatternCase('case').pattern;
46-
assertParsedNodeText(node, r'''
51+
assertResolvedNodeText(node, r'''
4752
CastPattern
4853
pattern: ConstantPattern
4954
expression: SimpleIdentifier
5055
token: y
56+
staticElement: self::@function::f::@parameter::y
57+
staticType: dynamic
5158
asToken: as
5259
type: NamedType
5360
name: SimpleIdentifier
5461
token: int
62+
staticElement: dart:core::@class::int
63+
staticType: null
64+
type: int
5565
''');
5666
}
5767
}

trunk/pkg/analyzer/test/src/dart/resolution/if_statement_test.dart

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ main() {
1515

1616
@reflectiveTest
1717
class IfStatementCaseResolutionTest extends PatternsResolutionTest {
18-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/50077')
1918
test_caseClause_rewrite() async {
2019
await assertNoErrorsInCode(r'''
2120
void f(x, int Function() a) {
@@ -25,7 +24,32 @@ void f(x, int Function() a) {
2524

2625
final node = findNode.ifStatement('if');
2726
assertResolvedNodeText(node, r'''
28-
TODO
27+
IfStatement
28+
ifKeyword: if
29+
leftParenthesis: (
30+
condition: SimpleIdentifier
31+
token: x
32+
staticElement: self::@function::f::@parameter::x
33+
staticType: dynamic
34+
caseClause: CaseClause
35+
caseKeyword: case
36+
pattern: ConstantPattern
37+
const: const
38+
expression: FunctionExpressionInvocation
39+
function: SimpleIdentifier
40+
token: a
41+
staticElement: self::@function::f::@parameter::a
42+
staticType: int Function()
43+
argumentList: ArgumentList
44+
leftParenthesis: (
45+
rightParenthesis: )
46+
staticElement: <null>
47+
staticInvokeType: int Function()
48+
staticType: int
49+
rightParenthesis: )
50+
thenStatement: Block
51+
leftBracket: {
52+
rightBracket: }
2953
''');
3054
}
3155

0 commit comments

Comments
 (0)