Files
sdk/pkg/front_end/testcases/nnbd/required_2.dart
T
Lasse R.H. Nielsen 711e50389f Remove var and final from parameters in pkg/.
Doesn't change anything in `front_end/*testcases/primary_constructors/`.
(Would have skipped any other file with `test` in its path and
an explicit language version marker, but there weren't any outside
of those `front_end` directories).

Almost no files used as test input were affected, and none testing the actual syntax changed.
The `.../nnbd/required_2.dart` test case was split into a legacy version retaining the `var`/`final` with a language marker, and a new version without the `var`/`final` cases.

The `pkg/analyzer/` tests, and any other tests that have source code
in strings, are not migrated by this CL.

Tested: No change to behavior. One test split into legacy and new.
Change-Id: I7f5aa4cc98001a9adecacd106c0b3be14f96be1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480542
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2026-04-10 09:09:39 -07:00

59 lines
1.4 KiB
Dart

// Copyright (c) 2026, 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.
// Test intended for post-primary constructors language versions, where
// `final` cannot occur in non-primary parameters.
method({int a = 42, required int b, required int c}) {}
class Class {
method(
{int a = 42,
required int b,
required covariant int c}) {}
}
// TODO(johnniwinther): Pass the required property to the function types.
typedef Typedef1 = Function({int a, required int b});
typedef Typedef2({int a, required int b});
Function({int a, required int b}) field = ({int a = 42, required int b}) {};
abstract class A {
// It's ok to omit the default values in abstract members.
foo({int x});
}
class B extends A {
// This is an implementation and it should have the default value.
foo({x}) {}
}
class C extends A {
foo({x = 42}) {}
}
ok() {
Function({int a, required int b}) f;
void g({int a = 42, required int b}) {}
f = ({int a = 42, required int b}) {};
Function(int a, [int b]) f2;
void g2(int a, [int b = 42]) {}
f2 = (int a, [int b = 42]) {};
}
error() {
Function({int a, required int b}) f;
void g({int a, required int b = 42}) {}
f = ({int a, required int b = 42}) {};
Function(int a = 42, [int b]) f2;
void g2(int a = 42, [int b]) {}
f2 = (int a = 42, [int b]) {};
}
main() {}