Skip to content

Commit 7359264

Browse files
chloestefantsovaCommit Bot
authored and
Commit Bot
committed
Revert "[parser] Add support for typed super-initializer parameters"
This reverts commit fc9f7e3. Reason for revert: breakages in ternary operators involving super access. Original change's description: > [parser] Add support for typed super-initializer parameters > > Part of #47525 > > Closes #47741 > > Bug: #47741 > Change-Id: I0558b33aa43cc73e67ca0d17bd5c8ec1afdc526f > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221634 > Commit-Queue: Chloe Stefantsova <[email protected]> > Reviewed-by: Johnni Winther <[email protected]> # Not skipping CQ checks because original CL landed > 1 day ago. Bug: #47741 Change-Id: I565faadeb0776a089853dc2264af50b069e16056 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222301 Reviewed-by: Chloe Stefantsova <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 6de562d commit 7359264

16 files changed

+173
-723
lines changed

pkg/_fe_analyzer_shared/lib/src/parser/type_info_impl.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ class VoidType implements TypeInfo {
451451
bool looksLikeName(Token token) {
452452
return token.kind == IDENTIFIER_TOKEN ||
453453
optional('this', token) ||
454-
optional('super', token) ||
455454
(token.isIdentifier &&
456455
// Although `typedef` is a legal identifier,
457456
// type `typedef` identifier is not legal and in this situation
@@ -795,9 +794,7 @@ class ComplexTypeInfo implements TypeInfo {
795794
if (optional('?', next)) {
796795
next = next.next!;
797796
}
798-
if (!(next.isIdentifier ||
799-
optional('this', next) ||
800-
optional('super', next))) {
797+
if (!(next.isIdentifier || optional('this', next))) {
801798
break; // `Function` used as the name in a function declaration.
802799
}
803800
}

pkg/analyzer/test/generated/utilities_test.dart

+1
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,7 @@ enum E2 {two; void bar() {}}
21522152
node, Getter_NodeReplacerTest_test_superConstructorInvocation_2());
21532153
}
21542154

2155+
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/47741')
21552156
void test_superFormalParameter() {
21562157
var findNode = _parseStringToFindNode(r'''
21572158
class A {

pkg/front_end/parser_testcases/error_recovery/keyword_named_class_fields.dart.intertwined.expect

+22-21
Original file line numberDiff line numberDiff line change
@@ -1471,27 +1471,28 @@ parseUnit(class)
14711471
listener: beginMetadataStar(int)
14721472
listener: endMetadataStar(0)
14731473
listener: beginMember()
1474-
recoverFromInvalidMember(int, ;, null, null, null, null, null, null, ;, Instance of 'SimpleType', null, DeclarationKind.Class, WrapperClass)
1475-
parseFields(;, null, null, null, null, null, null, ;, Instance of 'SimpleType', super, DeclarationKind.Class, WrapperClass, false)
1476-
listener: beginFields(DeclarationKind.Class, null, null, null, null, null, null, ;)
1477-
listener: handleIdentifier(int, typeReference)
1478-
listener: handleNoTypeArguments(super)
1479-
listener: handleType(int, null)
1480-
ensureIdentifierPotentiallyRecovered(int, fieldDeclaration, false)
1481-
reportRecoverableErrorWithToken(super, Instance of 'Template<(Token) => Message>')
1482-
listener: handleRecoverableError(Message[ExpectedIdentifierButGotKeyword, 'super' can't be used as an identifier because it's a keyword., Try renaming this to be an identifier that isn't a keyword., {lexeme: super}], super, super)
1483-
listener: handleIdentifier(super, fieldDeclaration)
1484-
parseFieldInitializerOpt(super, super, null, null, null, null, DeclarationKind.Class, WrapperClass)
1485-
listener: beginFieldInitializer(=)
1486-
parseExpression(=)
1487-
parsePrecedenceExpression(=, 1, true)
1488-
parseUnaryExpression(=, true)
1489-
parsePrimary(=, expression)
1490-
parseLiteralInt(=)
1491-
listener: handleLiteralInt(42)
1492-
listener: endFieldInitializer(=, ;)
1493-
listener: endClassFields(null, null, null, null, null, null, 1, int, ;)
1494-
listener: endMember()
1474+
isReservedKeyword(super)
1475+
indicatesMethodOrField(=)
1476+
parseFields(;, null, null, null, null, null, null, ;, Instance of 'SimpleType', super, DeclarationKind.Class, WrapperClass, true)
1477+
listener: beginFields(DeclarationKind.Class, null, null, null, null, null, null, ;)
1478+
listener: handleIdentifier(int, typeReference)
1479+
listener: handleNoTypeArguments(super)
1480+
listener: handleType(int, null)
1481+
ensureIdentifierPotentiallyRecovered(int, fieldDeclaration, true)
1482+
reportRecoverableErrorWithToken(super, Instance of 'Template<(Token) => Message>')
1483+
listener: handleRecoverableError(Message[ExpectedIdentifierButGotKeyword, 'super' can't be used as an identifier because it's a keyword., Try renaming this to be an identifier that isn't a keyword., {lexeme: super}], super, super)
1484+
listener: handleIdentifier(super, fieldDeclaration)
1485+
parseFieldInitializerOpt(super, super, null, null, null, null, DeclarationKind.Class, WrapperClass)
1486+
listener: beginFieldInitializer(=)
1487+
parseExpression(=)
1488+
parsePrecedenceExpression(=, 1, true)
1489+
parseUnaryExpression(=, true)
1490+
parsePrimary(=, expression)
1491+
parseLiteralInt(=)
1492+
listener: handleLiteralInt(42)
1493+
listener: endFieldInitializer(=, ;)
1494+
listener: endClassFields(null, null, null, null, null, null, 1, int, ;)
1495+
listener: endMember()
14951496
notEofOrValue(}, int)
14961497
parseClassOrMixinOrExtensionOrEnumMemberImpl(;, DeclarationKind.Class, WrapperClass)
14971498
parseMetadataStar(;)

pkg/front_end/parser_testcases/error_recovery/keyword_named_class_methods.dart.expect

+4-23
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,6 @@ parser/error_recovery/keyword_named_class_methods:282:7: 'super' can't be used a
308308
int super(int x) {
309309
^^^^^
310310

311-
parser/error_recovery/keyword_named_class_methods:282:7: Expected ';' after this.
312-
int super(int x) {
313-
^^^^^
314-
315-
parser/error_recovery/keyword_named_class_methods:282:12: Expected an identifier, but got '('.
316-
int super(int x) {
317-
^
318-
319311
parser/error_recovery/keyword_named_class_methods:287:7: 'switch' can't be used as an identifier because it's a keyword.
320312
int switch(int x) {
321313
^^^^^^
@@ -3891,23 +3883,12 @@ beginCompilationUnit(class)
38913883
beginMetadataStar(int)
38923884
endMetadataStar(0)
38933885
beginMember()
3894-
beginFields(DeclarationKind.Class, null, null, null, null, null, null, })
3886+
beginMethod(DeclarationKind.Class, null, null, null, null, null, super)
38953887
handleIdentifier(int, typeReference)
38963888
handleNoTypeArguments(super)
38973889
handleType(int, null)
38983890
handleRecoverableError(Message[ExpectedIdentifierButGotKeyword, 'super' can't be used as an identifier because it's a keyword., Try renaming this to be an identifier that isn't a keyword., {lexeme: super}], super, super)
3899-
handleIdentifier(super, fieldDeclaration)
3900-
handleNoFieldInitializer(()
3901-
handleRecoverableError(Message[ExpectedAfterButGot, Expected ';' after this., null, {string: ;}], super, super)
3902-
endClassFields(null, null, null, null, null, null, 1, int, ;)
3903-
endMember()
3904-
beginMetadataStar(()
3905-
endMetadataStar(0)
3906-
beginMember()
3907-
beginMethod(DeclarationKind.Class, null, null, null, null, null, ()
3908-
handleNoType(;)
3909-
handleRecoverableError(Message[ExpectedIdentifier, Expected an identifier, but got '('., Try inserting an identifier before '('., {lexeme: (}], (, ()
3910-
handleIdentifier(, methodDeclaration)
3891+
handleIdentifier(super, methodDeclaration)
39113892
handleNoTypeVariables(()
39123893
beginFormalParameters((, MemberKind.NonStaticMethod)
39133894
beginMetadataStar(int)
@@ -3956,7 +3937,7 @@ beginCompilationUnit(class)
39563937
endBinaryExpression(+)
39573938
endReturnStatement(true, return, ;)
39583939
endBlockFunctionBody(2, {, })
3959-
endClassMethod(null, , (, null, })
3940+
endClassMethod(null, int, (, null, })
39603941
endMember()
39613942
beginMetadataStar(int)
39623943
endMetadataStar(0)
@@ -4762,7 +4743,7 @@ beginCompilationUnit(class)
47624743
endBlockFunctionBody(2, {, })
47634744
endClassMethod(null, int, (, null, })
47644745
endMember()
4765-
endClassOrMixinOrExtensionBody(DeclarationKind.Class, 71, {, })
4746+
endClassOrMixinOrExtensionBody(DeclarationKind.Class, 70, {, })
47664747
endClassDeclaration(class, })
47674748
endTopLevelDeclaration()
47684749
endCompilationUnit(1, )

0 commit comments

Comments
 (0)