Files
sdk/pkg/front_end/testcases/nnbd/required_2.dart.strong.modular.expect
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

106 lines
4.8 KiB
Plaintext

library;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/required_2.dart:31:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
// Try adding either an explicit non-'null' default value or the 'required' modifier.
// foo({x}) {}
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:53:18: Error: Non-optional parameters can't have a default value.
// Try removing the default value or making the parameter optional.
// Function(int a = 42, [int b]) f2;
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:54:17: Error: Non-optional parameters can't have a default value.
// Try removing the default value or making the parameter optional.
// void g2(int a = 42, [int b]) {}
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:55:15: Error: Non-optional parameters can't have a default value.
// Try removing the default value or making the parameter optional.
// f2 = (int a = 42, [int b]) {};
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:50:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
// Try adding either an explicit non-'null' default value or the 'required' modifier.
// void g({int a, required int b = 42}) {}
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:50:31: Error: Named parameter 'b' is required and can't have a default value.
// void g({int a, required int b = 42}) {}
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:51:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
// Try adding either an explicit non-'null' default value or the 'required' modifier.
// f = ({int a, required int b = 42}) {};
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:51:29: Error: Named parameter 'b' is required and can't have a default value.
// f = ({int a, required int b = 42}) {};
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:54:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
// Try adding either an explicit non-'null' default value or the 'required' modifier.
// void g2(int a = 42, [int b]) {}
// ^
//
// pkg/front_end/testcases/nnbd/required_2.dart:55:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
// Try adding either an explicit non-'null' default value or the 'required' modifier.
// f2 = (int a = 42, [int b]) {};
// ^
//
import self as self;
import "dart:core" as core;
typedef Typedef1 = ({a: core::int, required b: core::int}) → dynamic;
typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int a = #C1, required core::int b, required covariant-by-declaration core::int c}) → dynamic {}
}
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
abstract method foo({core::int x = #C2}) → dynamic;
}
class B extends self::A {
synthetic constructor •() → self::B
: super self::A::•()
;
method foo({erroneously-initialized core::int x = #C2}) → dynamic {}
}
class C extends self::A {
synthetic constructor •() → self::C
: super self::A::•()
;
method foo({core::int x = #C1}) → dynamic {}
}
static field ({a: core::int, required b: core::int}) → dynamic field = ({core::int a = #C1, required core::int b}) → Null {};
static method method({core::int a = #C1, required core::int b, required core::int c}) → dynamic {}
static method ok() → dynamic {
({a: core::int, required b: core::int}) → dynamic f;
function g({core::int a = #C1, required core::int b}) → void {}
f = ({core::int a = #C1, required core::int b}) → Null {};
(core::int, [core::int]) → dynamic f2;
function g2(core::int a, [core::int b = #C1]) → void {}
f2 = (core::int a, [core::int b = #C1]) → Null {};
}
static method error() → dynamic {
({a: core::int, required b: core::int}) → dynamic f;
function g({erroneously-initialized core::int a = #C2, required core::int b = #C1}) → void {}
f = ({erroneously-initialized core::int a = #C2, required core::int b = #C1}) → Null {};
(core::int, [core::int]) → dynamic f2;
function g2(core::int a = #C1, [erroneously-initialized core::int b = #C2]) → void {}
f2 = (core::int a = #C1, [erroneously-initialized core::int b = #C2]) → Null {};
}
static method main() → dynamic {}
constants {
#C1 = 42
#C2 = null
}