blob: ca17aab22dcbc4fece6daf2fd8da89db88cc70c8 [file]
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// 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.
/// @assertion Consider a class, mixin class, enum, or extension type
/// declaration `D` with a primary constructor (note that it cannot be a
/// `<mixinApplicationClass>`, because that kind of declaration does not
/// syntactically support primary constructors). This declaration is treated as
/// a class, mixin class, enum, respectively extension type declaration without
/// a primary constructor which is obtained as described in the following. This
/// determines the dynamic semantics of a primary constructor.
/// ...
/// If `D` is an extension type, it is a compile-time error if the primary
/// constructor that `D` contains does not have exactly one parameter.
///
/// @description Check that it is a compile-time error if an extension type does
/// not contain a primary constructor that has exactly one declaring parameter
/// which is `final`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=primary-constructors
extension type const ET1(var int v) {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
extension type ET2.someName(var int v) {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
extension type ET3([var int v = 0]) {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
extension type const ET4.someName([var int v = 0]) {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
extension type const ET5({var int v = 0}) {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
extension type ET6.someName({var int v = 0}) {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
extension type ET7({required var int v}) {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
extension type const ET8.someName({required var int v}) {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
main() {
print(ET1);
print(ET2);
print(ET3);
print(ET4);
print(ET5);
print(ET6);
print(ET7);
print(ET8);
}