Files
sdk/pkg/front_end/parser_testcases/patterns/patternVariableDeclaration_inClass.dart.expect
T
Johnni Winther 49eb514005 [parser] Support primary constructor on classes, enums and extension types
This adds simple support for primary constructors in class, enum and extension type declarations. Declaring formals are not supported yet.

Change-Id: I2fb2cb3a819e38ec4ffe961da4713a871ac29a0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-10-17 01:52:11 -07:00

40 lines
1.6 KiB
Plaintext

Problems reported:
parser/patterns/patternVariableDeclaration_inClass:2:7: A pattern variable declaration may not appear outside a function or method.
var (a, b) = (0, 1);
^^^^^^
beginCompilationUnit(class)
beginMetadataStar(class)
endMetadataStar(0)
beginClassOrMixinOrNamedMixinApplicationPrelude(class)
handleIdentifier(C, classOrMixinDeclaration)
handleNoTypeVariables({)
beginClassDeclaration(class, null, null, null, null, null, null, null, null, C)
handleNoPrimaryConstructor(C, null, false)
handleNoType(C)
handleClassExtends(null, 1)
handleClassNoWithClause()
handleImplements(null, 0)
handleClassHeader(class, class, null)
beginClassOrMixinOrExtensionBody(DeclarationKind.Class, {)
beginMetadataStar(var)
endMetadataStar(0)
beginMember()
handleRecoverableError(PatternVariableDeclarationOutsideFunctionOrMethod, (, ))
beginFields(DeclarationKind.Class, null, null, null, null, null, null, var, {)
handleNoType(var)
handleIdentifier(, fieldDeclaration)
beginFieldInitializer(=)
beginParenthesizedExpressionOrRecordLiteral(()
handleLiteralInt(0)
handleLiteralInt(1)
endRecordLiteral((, 2, null)
endFieldInitializer(=, ))
endClassFields(null, null, null, null, null, null, var, 1, var, ;)
endMember()
endClassOrMixinOrExtensionBody(DeclarationKind.Class, 1, {, })
endClassDeclaration(class, })
endTopLevelDeclaration(})
endCompilationUnit(1, )