Skip to content

Commit 5cebb0f

Browse files
eernstgCommit Queue
authored and
Commit Queue
committed
Adjust Dart.g such that an extension can not have the name type
The declaration `extension type on(int i,) {}` is ambiguous: It can be an extension named `type` or an extension type named `on`. This CL adjusts the specification grammar Dart.g such that it is disambiguated in favor of being an extension type. See dart-lang/language#3258 for details. Change-Id: I74f800a75c6c5061675c345c546a85cff046d27f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332243 Reviewed-by: William Hesse <[email protected]> Commit-Queue: Erik Ernst <[email protected]>
1 parent c87fec8 commit 5cebb0f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tools/spec_parser/Dart.g

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ extensionTypeMemberDeclaration
460460
;
461461
462462
extensionDeclaration
463-
: EXTENSION identifier? typeParameters? ON type
463+
: EXTENSION typeIdentifierNotType? typeParameters? ON type
464464
LBRACE (metadata extensionMemberDefinition)* RBRACE
465465
;
466466
@@ -1046,13 +1046,18 @@ qualifiedName
10461046
| typeIdentifier '.' typeIdentifier '.' identifierOrNew
10471047
;
10481048
1049-
typeIdentifier
1049+
typeIdentifierNotType
10501050
: IDENTIFIER
10511051
| DYNAMIC // Built-in identifier that can be used as a type.
1052-
| otherIdentifier // Occur in grammar rules, are not built-in.
1052+
| otherIdentifierNotType // Occur in grammar rules, are not built-in.
10531053
| { asyncEtcPredicate(getCurrentToken().getType()) }? (AWAIT|YIELD)
10541054
;
10551055
1056+
typeIdentifier
1057+
: typeIdentifierNotType
1058+
| TYPE
1059+
;
1060+
10561061
typeTest
10571062
: isOperator typeNotVoid
10581063
;
@@ -1637,7 +1642,7 @@ builtInIdentifier
16371642
| TYPEDEF
16381643
;
16391644
1640-
otherIdentifier
1645+
otherIdentifierNotType
16411646
: ASYNC
16421647
| BASE
16431648
| HIDE
@@ -1646,10 +1651,14 @@ otherIdentifier
16461651
| SEALED
16471652
| SHOW
16481653
| SYNC
1649-
| TYPE
16501654
| WHEN
16511655
;
16521656
1657+
otherIdentifier
1658+
: otherIdentifierNotType
1659+
| TYPE
1660+
;
1661+
16531662
// ---------------------------------------- Lexer rules.
16541663
16551664
fragment

0 commit comments

Comments
 (0)