Skip to content

Commit 8e5b70a

Browse files
scheglovCommit Queue
authored and
Commit Queue
committed
Augment. Store AugmentedInvocation() node into summary.
Change-Id: Ida7fef456e2dfd54448bca5018b5b54a255167b8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365681 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent 3a324fa commit 8e5b70a

File tree

6 files changed

+99
-2
lines changed

6 files changed

+99
-2
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import 'package:meta/meta.dart';
9595
// TODO(scheglov): Clean up the list of implicitly analyzed files.
9696
class AnalysisDriver {
9797
/// The version of data format, should be incremented on every format change.
98-
static const int DATA_VERSION = 363;
98+
static const int DATA_VERSION = 364;
9999

100100
/// The number of exception contexts allowed to write. Once this field is
101101
/// zero, we stop writing any new exception contexts in this process.

pkg/analyzer/lib/src/summary2/ast_binary_reader.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class AstBinaryReader {
4444
return _readAssignmentExpression();
4545
case Tag.AugmentedExpression:
4646
return _readAugmentedExpression();
47+
case Tag.AugmentedInvocation:
48+
return _readAugmentedInvocation();
4749
case Tag.AwaitExpression:
4850
return _readAwaitExpression();
4951
case Tag.BinaryExpression:
@@ -284,6 +286,20 @@ class AstBinaryReader {
284286
return node;
285287
}
286288

289+
AugmentedInvocation _readAugmentedInvocation() {
290+
var typeArguments = _readOptionalNode() as TypeArgumentListImpl?;
291+
var arguments = readNode() as ArgumentListImpl;
292+
293+
var node = AugmentedInvocationImpl(
294+
augmentedKeyword: Tokens.augmented(),
295+
typeArguments: typeArguments,
296+
arguments: arguments,
297+
);
298+
node.element = _reader.readElement() as ExecutableElement?;
299+
_readExpressionResolution(node);
300+
return node;
301+
}
302+
287303
AwaitExpression _readAwaitExpression() {
288304
var expression = readNode() as ExpressionImpl;
289305
return AwaitExpressionImpl(
@@ -1294,7 +1310,7 @@ class AstBinaryReader {
12941310
return node;
12951311
}
12961312

1297-
TypeArgumentList _readTypeArgumentList() {
1313+
TypeArgumentListImpl _readTypeArgumentList() {
12981314
var arguments = _readNodeList<TypeAnnotationImpl>();
12991315
return TypeArgumentListImpl(
13001316
leftBracket: Tokens.lt(),

pkg/analyzer/lib/src/summary2/ast_binary_tag.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Tag {
4949
static const int AssertInitializer = 82;
5050
static const int AssignmentExpression = 96;
5151
static const int AugmentedExpression = 111;
52+
static const int AugmentedInvocation = 112;
5253
static const int AwaitExpression = 100;
5354
static const int BinaryExpression = 52;
5455
static const int BooleanLiteral = 4;

pkg/analyzer/lib/src/summary2/ast_binary_writer.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ class AstBinaryWriter extends ThrowingAstVisitor<void> {
9999
_storeExpression(node);
100100
}
101101

102+
@override
103+
void visitAugmentedInvocation(AugmentedInvocation node) {
104+
_writeByte(Tag.AugmentedInvocation);
105+
_writeOptionalNode(node.typeArguments);
106+
_writeNode(node.arguments);
107+
_sink.writeElement(node.element);
108+
_storeExpression(node);
109+
}
110+
102111
@override
103112
void visitAwaitExpression(AwaitExpression node) {
104113
_writeByte(Tag.AwaitExpression);

pkg/analyzer/lib/src/summary2/informative_data.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,12 @@ abstract class _OffsetsAstVisitor extends RecursiveAstVisitor<void> {
22362236
super.visitAugmentedExpression(node);
22372237
}
22382238

2239+
@override
2240+
void visitAugmentedInvocation(AugmentedInvocation node) {
2241+
_tokenOrNull(node.augmentedKeyword);
2242+
super.visitAugmentedInvocation(node);
2243+
}
2244+
22392245
@override
22402246
void visitBinaryExpression(BinaryExpression node) {
22412247
_tokenOrNull(node.operator);

pkg/analyzer/test/src/summary/elements_test.dart

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,71 @@ library
14401440
''');
14411441
}
14421442

1443+
test_augmented_field_augment_field_augmentedInvocation() async {
1444+
// This is invalid code, but it should not crash.
1445+
newFile('$testPackageLibPath/a.dart', r'''
1446+
augment library 'test.dart';
1447+
augment class A {;
1448+
augment static const int foo = augmented();
1449+
}
1450+
''');
1451+
1452+
var library = await buildLibrary(r'''
1453+
import augment 'a.dart';
1454+
class A {
1455+
static const int foo = 0;
1456+
}
1457+
''');
1458+
1459+
checkElementText(library, r'''
1460+
library
1461+
definingUnit
1462+
classes
1463+
class A @31
1464+
augmentation: self::@augmentation::package:test/a.dart::@classAugmentation::A
1465+
fields
1466+
static const foo @54
1467+
type: int
1468+
shouldUseTypeForInitializerInference: true
1469+
constantInitializer
1470+
IntegerLiteral
1471+
literal: 0 @60
1472+
staticType: int
1473+
augmentation: self::@augmentation::package:test/a.dart::@classAugmentation::A::@fieldAugmentation::foo
1474+
constructors
1475+
synthetic @-1
1476+
accessors
1477+
synthetic static get foo @-1
1478+
returnType: int
1479+
augmented
1480+
fields
1481+
self::@augmentation::package:test/a.dart::@classAugmentation::A::@fieldAugmentation::foo
1482+
constructors
1483+
self::@class::A::@constructor::new
1484+
accessors
1485+
self::@class::A::@getter::foo
1486+
augmentationImports
1487+
package:test/a.dart
1488+
definingUnit
1489+
classes
1490+
augment class A @43
1491+
augmentationTarget: self::@class::A
1492+
fields
1493+
augment static const foo @75
1494+
type: int
1495+
shouldUseTypeForInitializerInference: true
1496+
constantInitializer
1497+
AugmentedInvocation
1498+
augmentedKeyword: augmented @81
1499+
arguments: ArgumentList
1500+
leftParenthesis: ( @90
1501+
rightParenthesis: ) @91
1502+
element: <null>
1503+
staticType: InvalidType
1504+
augmentationTarget: self::@class::A::@field::foo
1505+
''');
1506+
}
1507+
14431508
test_augmented_field_augment_field_differentTypes() async {
14441509
newFile('$testPackageLibPath/a.dart', r'''
14451510
augment library 'test.dart';

0 commit comments

Comments
 (0)