From 86232e2c3a45a573a862212bbee34bf8438a162c Mon Sep 17 00:00:00 2001 From: Kallen Tu Date: Thu, 5 Mar 2026 11:12:02 -0800 Subject: [PATCH] [tests] Primary constructors - Allow ; bodies on any membered declarations. Updating some primary constructor tests in light of issue 4645 that allows `;` on any membered declarations. Bug: https://github.com/dart-lang/language/issues/4645, https://github.com/dart-lang/sdk/issues/61687 Change-Id: I390ccd1eb1c84d55ee599d4d94ab199bb4920880 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485585 Commit-Queue: Kallen Tu Reviewed-by: Erik Ernst --- .../syntax/empty_body_error_test.dart | 21 +--------- .../syntax/empty_body_test.dart | 38 ++++++++++++++++--- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/tests/language/primary_constructors/syntax/empty_body_error_test.dart b/tests/language/primary_constructors/syntax/empty_body_error_test.dart index 2d8cd552b84..bb85f80da0b 100644 --- a/tests/language/primary_constructors/syntax/empty_body_error_test.dart +++ b/tests/language/primary_constructors/syntax/empty_body_error_test.dart @@ -2,28 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// For mixins, an empty body, `{}`, cannot be replaced by `;`. Enums require a -// non-empty declaration. +// Enums that have an empty body (i.e. `;`) can be parsed, but will cause a +// compile-time error when there's no enum constant declared. // SharedOptions=--enable-experiment=primary-constructors -class C1; - -mixin M1; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - -mixin M2 implements C1; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - -mixin M3 on C1; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - enum E1; // ^ // [analyzer] unspecified diff --git a/tests/language/primary_constructors/syntax/empty_body_test.dart b/tests/language/primary_constructors/syntax/empty_body_test.dart index d0808def27c..ada8df63dc6 100644 --- a/tests/language/primary_constructors/syntax/empty_body_test.dart +++ b/tests/language/primary_constructors/syntax/empty_body_test.dart @@ -2,28 +2,56 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// An empty class body, `{}`, can be replaced by `;`. +// An empty declaration body, `{}`, can be replaced by `;`. // SharedOptions=--enable-experiment=primary-constructors +// Classes class C1; class C2 with M1; class C3(var int x) extends C1; -mixin class M1 implements C1; - -mixin class M2; - +// Extension types extension type E1(int x); extension type const E2(int x); +// Mixin classes +mixin class M1 implements C1; + +class M1With with M1; + +mixin class M2; + +class M2With with M2; + +// Mixins +mixin M3; + +class M3With with M3; + +mixin M4 implements C1; + +class M4With with M4; + +mixin M5 on C1; + +class M5With extends C1 with M5; + +// Extension +extension Ext1 on C1; + void main() { print(C1()); print(C2()); print(C3(1)); print(E1(1)); print(E2(1)); + print(M1With()); + print(M2With()); + print(M3With()); + print(M4With()); + print(M5With()); }