[cfe][PrimaryConstructors] Add AsyncModifier

This adds an AsyncModifier class that holds both the AsyncMarker, used in the kernel encoding, and the file offset of the async modifier. This is used throughout the front end and ensures that the correct offset is used for errors reported on the async modifier.

Change-Id: If16d293ffb9b2e8fa8eca8c65f7548d920c5d56b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther
2026-05-06 01:35:05 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 0cbc0c3d82
commit a782aed439
45 changed files with 1474 additions and 174 deletions
@@ -9,7 +9,6 @@ class A() {
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.PRIMARY_CONSTRUCTOR_BODY_WITH_MODIFIER
// [cfe] A primary constructor body can't have the modifier 'async'.
// ^
// [cfe] Constructor bodies can't use 'async', 'async*', or 'sync*'.
}
@@ -18,7 +17,6 @@ class B() {
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.PRIMARY_CONSTRUCTOR_BODY_WITH_MODIFIER
// [cfe] A primary constructor body can't have the modifier 'async*'.
// ^
// [cfe] Constructor bodies can't use 'async', 'async*', or 'sync*'.
}
@@ -27,7 +25,6 @@ class C() {
// ^^^^
// [analyzer] SYNTACTIC_ERROR.PRIMARY_CONSTRUCTOR_BODY_WITH_MODIFIER
// [cfe] A primary constructor body can't have the modifier 'sync*'.
// ^
// [cfe] Constructor bodies can't use 'async', 'async*', or 'sync*'.
}
@@ -39,10 +36,10 @@ enum E() {
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.PRIMARY_CONSTRUCTOR_BODY_WITH_MODIFIER
// [cfe] A primary constructor body can't have the modifier 'async'.
// [cfe] Constructor bodies can't use 'async', 'async*', or 'sync*'.
// ^
// [analyzer] COMPILE_TIME_ERROR.CONST_PRIMARY_CONSTRUCTOR_WITH_BODY
// [cfe] A const constructor can't have a body.
// [cfe] Constructor bodies can't use 'async', 'async*', or 'sync*'.
}
extension type ET(int x) {
@@ -50,6 +47,5 @@ extension type ET(int x) {
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.PRIMARY_CONSTRUCTOR_BODY_WITH_MODIFIER
// [cfe] A primary constructor body can't have the modifier 'async'.
// ^
// [cfe] Constructor bodies can't use 'async', 'async*', or 'sync*'.
}