[cfe] Check optional non-nullable parameters in constructors

Closes #42203
Closes #42362
Closes #42352

Change-Id: Ida8a41252ec524ba5c2eaa697fa61e3514897bef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151500
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2020-06-18 18:07:06 +00:00 committed by commit-bot@chromium.org
parent f591ad7d88
commit 87f74cbba9
21 changed files with 1126 additions and 30 deletions

View file

@ -326,12 +326,12 @@ class KernelTarget extends TargetImplementation {
loader.computeHierarchy();
loader.performTopLevelInference(myClasses);
loader.checkSupertypes(myClasses);
loader.checkTypes();
loader.checkOverrides(myClasses);
loader.checkAbstractMembers(myClasses);
loader.addNoSuchMethodForwarders(myClasses);
loader.checkMixins(myClasses);
loader.buildOutlineExpressions(loader.coreTypes);
loader.checkTypes();
loader.checkRedirectingFactories(myClasses);
_updateDelayedParameterTypes();
installAllComponentProblems(loader.allComponentProblems);

View file

@ -16,6 +16,7 @@ import 'package:kernel/type_environment.dart';
import '../builder/builder.dart';
import '../builder/class_builder.dart';
import '../builder/constructor_builder.dart';
import '../builder/constructor_reference_builder.dart';
import '../builder/field_builder.dart';
import '../builder/function_builder.dart';
@ -582,7 +583,16 @@ class SourceClassBuilder extends ClassBuilderImpl
// Check initializers.
if (builder is FunctionBuilder &&
!builder.isAbstract &&
!(builder.isAbstract || builder.isExternal) &&
builder.formals != null) {
libraryBuilder.checkInitializersInFormals(
builder.formals, typeEnvironment);
}
});
constructors.local.forEach((String name, MemberBuilder builder) {
if (builder is ConstructorBuilder &&
!builder.isExternal &&
builder.formals != null) {
libraryBuilder.checkInitializersInFormals(
builder.formals, typeEnvironment);

View file

@ -16,5 +16,5 @@ class PatchedClass {
patch
*/
@patch
const PatchedClass({int field}) : _field = field;
const PatchedClass({int field: 0}) : _field = field;
}

View file

@ -1,3 +1,7 @@
// Copyright (c) 2020, 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.
import 'dart:async';
void h1<T extends FutureOr<T?>?>(T? t) {}

View file

@ -0,0 +1,109 @@
// Copyright (c) 2020, 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.
class A {
final int i;
A.constructor1([this.i]); // error
A.constructor2({this.i}); // error
A.constructor3([int i]) // error
: this.i = i; // ok
A.constructor4({int i}) // error
: this.i = i; // ok
A.constructor5([int? i]) // ok
: this.i = i; // error
A.constructor6({int? i}) // ok
: this.i = i; // error
A.constructor7({required int i}) // ok
: this.i = i; // ok
external A.constructor8([int i]); // ok
external A.constructor9({int i}); // ok
factory A.factory3([int i]) = A.constructor3; // ok
factory A.factory4({int i}) = A.constructor4; // ok
factory A.factory5([int? i]) = A.constructor5; // ok
factory A.factory6({int? i}) = A.constructor6; // ok
factory A.factory7({required int i}) = A.constructor7; // ok
method3([int i]) {} // error
method4({int i}) {} // error
method5([int? i]) {} // ok
method6({int? i}) {} // ok
method7({required int i}) {} // ok
external method8([int i]); // ok
external method9({int i}); // ok
}
abstract class B {
var i = 42;
method3([int i]); // ok
method4({int i}); // ok
method5([int? i]); // ok
method6({int? i}); // ok
method7({required int i}); // ok
}
class C implements B {
var i;
C.constructor1([this.i]); // error
C.constructor2({this.i}); // error
C.constructor3([int i]) : this.i = i; // error
C.constructor4({int i}) : this.i = i; // error
C.constructor5([int? i]) : this.i = i; // error
C.constructor6({int? i}) : this.i = i; // error
C.constructor7({required int i}) // ok
: this.i = i; // ok
factory C.factory3([int i]) = C.constructor3; // ok
factory C.factory4({int i}) = C.constructor4; // ok
factory C.factory5([int? i]) = C.constructor5; // ok
factory C.factory6({int? i}) = C.constructor6; // ok
factory C.factory7({required int i}) = C.constructor7; // ok
method3([i]) {} // error
method4({i}) {} // error
method5([i]) {} // ok
method6({i}) {} // ok
method7({required i}) {} // ok
}
void main() {}

View file

@ -0,0 +1,149 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/issue42362.dart:41:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([int i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:43:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({int i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:8:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:10:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:12:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor3([int i]) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:15:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor4({int i}) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:98:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:100:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:73:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:75:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:77:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor3([int i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:79:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor4({int i}) : this.i = i; // error
// ^
//
import self as self;
import "dart:core" as core;
class A extends core::Object {
final field core::int i;
static field dynamic _redirecting# = <dynamic>[self::A::factory3, self::A::factory4, self::A::factory5, self::A::factory6, self::A::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i]) → self::A
;
constructor constructor2({core::int i}) → self::A
;
constructor constructor3([core::int i]) → self::A
;
constructor constructor4({core::int i}) → self::A
;
constructor constructor5([core::int? i]) → self::A
;
constructor constructor6({core::int? i}) → self::A
;
constructor constructor7({required core::int i}) → self::A
;
external constructor constructor8([core::int i]) → self::A
;
external constructor constructor9({core::int i}) → self::A
;
static factory factory3([core::int i]) → self::A
let dynamic #redirecting_factory = self::A::constructor3 in invalid-expression;
static factory factory4({core::int i}) → self::A
let dynamic #redirecting_factory = self::A::constructor4 in invalid-expression;
static factory factory5([core::int? i]) → self::A
let dynamic #redirecting_factory = self::A::constructor5 in invalid-expression;
static factory factory6({core::int? i}) → self::A
let dynamic #redirecting_factory = self::A::constructor6 in invalid-expression;
static factory factory7({required core::int i}) → self::A
let dynamic #redirecting_factory = self::A::constructor7 in invalid-expression;
method method3([core::int i]) → dynamic
;
method method4({core::int i}) → dynamic
;
method method5([core::int? i]) → dynamic
;
method method6({core::int? i}) → dynamic
;
method method7({required core::int i}) → dynamic
;
external method method8([core::int i]) → dynamic;
external method method9({core::int i}) → dynamic;
}
abstract class B extends core::Object {
field core::int i;
synthetic constructor •() → self::B
;
abstract method method3([core::int i]) → dynamic;
abstract method method4({core::int i}) → dynamic;
abstract method method5([core::int? i]) → dynamic;
abstract method method6({core::int? i}) → dynamic;
abstract method method7({required core::int i}) → dynamic;
}
class C extends core::Object implements self::B {
field core::int i;
static field dynamic _redirecting# = <dynamic>[self::C::factory3, self::C::factory4, self::C::factory5, self::C::factory6, self::C::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i]) → self::C
;
constructor constructor2({core::int i}) → self::C
;
constructor constructor3([core::int i]) → self::C
;
constructor constructor4({core::int i}) → self::C
;
constructor constructor5([core::int? i]) → self::C
;
constructor constructor6({core::int? i}) → self::C
;
constructor constructor7({required core::int i}) → self::C
;
static factory factory3([core::int i]) → self::C
let dynamic #redirecting_factory = self::C::constructor3 in invalid-expression;
static factory factory4({core::int i}) → self::C
let dynamic #redirecting_factory = self::C::constructor4 in invalid-expression;
static factory factory5([core::int? i]) → self::C
let dynamic #redirecting_factory = self::C::constructor5 in invalid-expression;
static factory factory6({core::int? i}) → self::C
let dynamic #redirecting_factory = self::C::constructor6 in invalid-expression;
static factory factory7({required core::int i}) → self::C
let dynamic #redirecting_factory = self::C::constructor7 in invalid-expression;
method method3([core::int i]) → dynamic
;
method method4({core::int i}) → dynamic
;
method method5([core::int? i]) → dynamic
;
method method6({core::int? i}) → dynamic
;
method method7({required core::int i}) → dynamic
;
}
static method main() → void
;

View file

@ -0,0 +1,183 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/issue42362.dart:41:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([int i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:43:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({int i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:8:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:10:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:12:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor3([int i]) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:15:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor4({int i}) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:98:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:100:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:73:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:75:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:77:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor3([int i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:79:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor4({int i}) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:19:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:22:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:81:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// C.constructor5([int? i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:83:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// C.constructor6({int? i}) : this.i = i; // error
// ^
//
import self as self;
import "dart:core" as core;
class A extends core::Object {
final field core::int i;
static field dynamic _redirecting# = <dynamic>[self::A::factory3, self::A::factory4, self::A::factory5, self::A::factory6, self::A::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i = #C1]) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor2({core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor3([core::int i = #C1]) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor4({core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor5([core::int? i = #C1]) → self::A
: self::A::i = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:19:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
: this.i = i; // error
^" in i as{TypeError,ForNonNullableByDefault} core::int, super core::Object::•()
;
constructor constructor6({core::int? i = #C1}) → self::A
: self::A::i = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:22:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
: this.i = i; // error
^" in i as{TypeError,ForNonNullableByDefault} core::int, super core::Object::•()
;
constructor constructor7({required core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
external constructor constructor8([core::int i = #C1]) → self::A
: super core::Object::•()
;
external constructor constructor9({core::int i = #C1}) → self::A
: super core::Object::•()
;
static factory factory3([core::int i = #C1]) → self::A
let dynamic #redirecting_factory = self::A::constructor3 in invalid-expression;
static factory factory4({core::int i = #C1}) → self::A
let dynamic #redirecting_factory = self::A::constructor4 in invalid-expression;
static factory factory5([core::int? i = #C1]) → self::A
let dynamic #redirecting_factory = self::A::constructor5 in invalid-expression;
static factory factory6({core::int? i = #C1}) → self::A
let dynamic #redirecting_factory = self::A::constructor6 in invalid-expression;
static factory factory7({required core::int i = #C1}) → self::A
let dynamic #redirecting_factory = self::A::constructor7 in invalid-expression;
method method3([core::int i = #C1]) → dynamic {}
method method4({core::int i = #C1}) → dynamic {}
method method5([core::int? i = #C1]) → dynamic {}
method method6({core::int? i = #C1}) → dynamic {}
method method7({required core::int i = #C1}) → dynamic {}
external method method8([core::int i = #C1]) → dynamic;
external method method9({core::int i = #C1}) → dynamic;
}
abstract class B extends core::Object {
field core::int i = 42;
synthetic constructor •() → self::B
: super core::Object::•()
;
abstract method method3([core::int i = #C1]) → dynamic;
abstract method method4({core::int i = #C1}) → dynamic;
abstract method method5([core::int? i = #C1]) → dynamic;
abstract method method6({core::int? i = #C1}) → dynamic;
abstract method method7({required core::int i = #C1}) → dynamic;
}
class C extends core::Object implements self::B {
field core::int i;
static field dynamic _redirecting# = <dynamic>[self::C::factory3, self::C::factory4, self::C::factory5, self::C::factory6, self::C::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i = #C1]) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor2({core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor3([core::int i = #C1]) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor4({core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor5([core::int? i = #C1]) → self::C
: self::C::i = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:81:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
C.constructor5([int? i]) : this.i = i; // error
^" in i as{TypeError,ForNonNullableByDefault} core::int, super core::Object::•()
;
constructor constructor6({core::int? i = #C1}) → self::C
: self::C::i = let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:83:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
C.constructor6({int? i}) : this.i = i; // error
^" in i as{TypeError,ForNonNullableByDefault} core::int, super core::Object::•()
;
constructor constructor7({required core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
static factory factory3([core::int i = #C1]) → self::C
let dynamic #redirecting_factory = self::C::constructor3 in invalid-expression;
static factory factory4({core::int i = #C1}) → self::C
let dynamic #redirecting_factory = self::C::constructor4 in invalid-expression;
static factory factory5([core::int? i = #C1]) → self::C
let dynamic #redirecting_factory = self::C::constructor5 in invalid-expression;
static factory factory6({core::int? i = #C1}) → self::C
let dynamic #redirecting_factory = self::C::constructor6 in invalid-expression;
static factory factory7({required core::int i = #C1}) → self::C
let dynamic #redirecting_factory = self::C::constructor7 in invalid-expression;
method method3([core::int i = #C1]) → dynamic {}
method method4({core::int i = #C1}) → dynamic {}
method method5([core::int? i = #C1]) → dynamic {}
method method6({core::int? i = #C1}) → dynamic {}
method method7({required core::int i = #C1}) → dynamic {}
}
static method main() → void {}
constants {
#C1 = null
}

View file

@ -0,0 +1,183 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/issue42362.dart:41:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([int i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:43:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({int i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:8:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:10:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:12:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor3([int i]) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:15:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor4({int i}) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:98:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:100:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:73:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:75:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:77:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor3([int i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:79:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor4({int i}) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:19:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:22:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:81:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// C.constructor5([int? i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:83:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// C.constructor6({int? i}) : this.i = i; // error
// ^
//
import self as self;
import "dart:core" as core;
class A extends core::Object {
final field core::int i;
static field dynamic _redirecting# = <dynamic>[self::A::factory3, self::A::factory4, self::A::factory5, self::A::factory6, self::A::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i = #C1]) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor2({core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor3([core::int i = #C1]) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor4({core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor5([core::int? i = #C1]) → self::A
: self::A::i = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:19:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
: this.i = i; // error
^" in let core::int? #t2 = i in #t2.==(null) ?{core::int} #t2 as{TypeError,ForNonNullableByDefault} core::int : #t2{core::int}, super core::Object::•()
;
constructor constructor6({core::int? i = #C1}) → self::A
: self::A::i = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:22:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
: this.i = i; // error
^" in let core::int? #t4 = i in #t4.==(null) ?{core::int} #t4 as{TypeError,ForNonNullableByDefault} core::int : #t4{core::int}, super core::Object::•()
;
constructor constructor7({required core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
external constructor constructor8([core::int i = #C1]) → self::A
: super core::Object::•()
;
external constructor constructor9({core::int i = #C1}) → self::A
: super core::Object::•()
;
static factory factory3([core::int i = #C1]) → self::A
let<BottomType> #redirecting_factory = self::A::constructor3 in invalid-expression;
static factory factory4({core::int i = #C1}) → self::A
let<BottomType> #redirecting_factory = self::A::constructor4 in invalid-expression;
static factory factory5([core::int? i = #C1]) → self::A
let<BottomType> #redirecting_factory = self::A::constructor5 in invalid-expression;
static factory factory6({core::int? i = #C1}) → self::A
let<BottomType> #redirecting_factory = self::A::constructor6 in invalid-expression;
static factory factory7({required core::int i = #C1}) → self::A
let<BottomType> #redirecting_factory = self::A::constructor7 in invalid-expression;
method method3([core::int i = #C1]) → dynamic {}
method method4({core::int i = #C1}) → dynamic {}
method method5([core::int? i = #C1]) → dynamic {}
method method6({core::int? i = #C1}) → dynamic {}
method method7({required core::int i = #C1}) → dynamic {}
external method method8([core::int i = #C1]) → dynamic;
external method method9({core::int i = #C1}) → dynamic;
}
abstract class B extends core::Object {
field core::int i = 42;
synthetic constructor •() → self::B
: super core::Object::•()
;
abstract method method3([core::int i = #C1]) → dynamic;
abstract method method4({core::int i = #C1}) → dynamic;
abstract method method5([core::int? i = #C1]) → dynamic;
abstract method method6({core::int? i = #C1}) → dynamic;
abstract method method7({required core::int i = #C1}) → dynamic;
}
class C extends core::Object implements self::B {
field core::int i;
static field dynamic _redirecting# = <dynamic>[self::C::factory3, self::C::factory4, self::C::factory5, self::C::factory6, self::C::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i = #C1]) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor2({core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor3([core::int i = #C1]) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor4({core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor5([core::int? i = #C1]) → self::C
: self::C::i = let final<BottomType> #t5 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:81:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
C.constructor5([int? i]) : this.i = i; // error
^" in let core::int? #t6 = i in #t6.==(null) ?{core::int} #t6 as{TypeError,ForNonNullableByDefault} core::int : #t6{core::int}, super core::Object::•()
;
constructor constructor6({core::int? i = #C1}) → self::C
: self::C::i = let final<BottomType> #t7 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:83:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
C.constructor6({int? i}) : this.i = i; // error
^" in let core::int? #t8 = i in #t8.==(null) ?{core::int} #t8 as{TypeError,ForNonNullableByDefault} core::int : #t8{core::int}, super core::Object::•()
;
constructor constructor7({required core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
static factory factory3([core::int i = #C1]) → self::C
let<BottomType> #redirecting_factory = self::C::constructor3 in invalid-expression;
static factory factory4({core::int i = #C1}) → self::C
let<BottomType> #redirecting_factory = self::C::constructor4 in invalid-expression;
static factory factory5([core::int? i = #C1]) → self::C
let<BottomType> #redirecting_factory = self::C::constructor5 in invalid-expression;
static factory factory6({core::int? i = #C1}) → self::C
let<BottomType> #redirecting_factory = self::C::constructor6 in invalid-expression;
static factory factory7({required core::int i = #C1}) → self::C
let<BottomType> #redirecting_factory = self::C::constructor7 in invalid-expression;
method method3([core::int i = #C1]) → dynamic {}
method method4({core::int i = #C1}) → dynamic {}
method method5([core::int? i = #C1]) → dynamic {}
method method6({core::int? i = #C1}) → dynamic {}
method method7({required core::int i = #C1}) → dynamic {}
}
static method main() → void {}
constants {
#C1 = null
}

View file

@ -0,0 +1,56 @@
class A {
final int i;
A.constructor1([this.i]);
A.constructor2({this.i});
A.constructor3([int i]) : this.i = i;
A.constructor4({int i}) : this.i = i;
A.constructor5([int? i]) : this.i = i;
A.constructor6({int? i}) : this.i = i;
A.constructor7({required int i}) : this.i = i;
external A.constructor8([int i]);
external A.constructor9({int i});
factory A.factory3([int i]) = A.constructor3;
factory A.factory4({int i}) = A.constructor4;
factory A.factory5([int? i]) = A.constructor5;
factory A.factory6({int? i}) = A.constructor6;
factory A.factory7({required int i}) = A.constructor7;
method3([int i]) {}
method4({int i}) {}
method5([int? i]) {}
method6({int? i}) {}
method7({required int i}) {}
external method8([int i]);
external method9({int i});
}
abstract class B {
var i = 42;
method3([int i]);
method4({int i});
method5([int? i]);
method6({int? i});
method7({required int i});
}
class C implements B {
var i;
C.constructor1([this.i]);
C.constructor2({this.i});
C.constructor3([int i]) : this.i = i;
C.constructor4({int i}) : this.i = i;
C.constructor5([int? i]) : this.i = i;
C.constructor6({int? i}) : this.i = i;
C.constructor7({required int i}) : this.i = i;
factory C.factory3([int i]) = C.constructor3;
factory C.factory4({int i}) = C.constructor4;
factory C.factory5([int? i]) = C.constructor5;
factory C.factory6({int? i}) = C.constructor6;
factory C.factory7({required int i}) = C.constructor7;
method3([i]) {}
method4({i}) {}
method5([i]) {}
method6({i}) {}
method7({required i}) {}
}
void main() {}

View file

@ -0,0 +1,56 @@
abstract class B {
method3([int i]);
method4({int i});
method5([int? i]);
method6({int? i});
method7({required int i});
var i = 42;
}
class A {
A.constructor1([this.i]);
A.constructor2({this.i});
A.constructor3([int i]) : this.i = i;
A.constructor4({int i}) : this.i = i;
A.constructor5([int? i]) : this.i = i;
A.constructor6({int? i}) : this.i = i;
A.constructor7({required int i}) : this.i = i;
external A.constructor8([int i]);
external A.constructor9({int i});
external method8([int i]);
external method9({int i});
factory A.factory3([int i]) = A.constructor3;
factory A.factory4({int i}) = A.constructor4;
factory A.factory5([int? i]) = A.constructor5;
factory A.factory6({int? i}) = A.constructor6;
factory A.factory7({required int i}) = A.constructor7;
final int i;
method3([int i]) {}
method4({int i}) {}
method5([int? i]) {}
method6({int? i}) {}
method7({required int i}) {}
}
class C implements B {
C.constructor1([this.i]);
C.constructor2({this.i});
C.constructor3([int i]) : this.i = i;
C.constructor4({int i}) : this.i = i;
C.constructor5([int? i]) : this.i = i;
C.constructor6({int? i}) : this.i = i;
C.constructor7({required int i}) : this.i = i;
factory C.factory3([int i]) = C.constructor3;
factory C.factory4({int i}) = C.constructor4;
factory C.factory5([int? i]) = C.constructor5;
factory C.factory6({int? i}) = C.constructor6;
factory C.factory7({required int i}) = C.constructor7;
method3([i]) {}
method4({i}) {}
method5([i]) {}
method6({i}) {}
method7({required i}) {}
var i;
}
void main() {}

View file

@ -0,0 +1,183 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/issue42362.dart:41:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([int i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:43:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({int i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:8:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:10:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:12:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor3([int i]) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:15:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor4({int i}) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:98:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:100:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:73:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:75:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:77:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor3([int i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:79:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor4({int i}) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:19:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:22:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:81:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// C.constructor5([int? i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:83:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// C.constructor6({int? i}) : this.i = i; // error
// ^
//
import self as self;
import "dart:core" as core;
class A extends core::Object {
final field core::int i;
static field dynamic _redirecting# = <dynamic>[self::A::factory3, self::A::factory4, self::A::factory5, self::A::factory6, self::A::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i = #C1]) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor2({core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor3([core::int i = #C1]) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor4({core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor5([core::int? i = #C1]) → self::A
: self::A::i = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:19:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
: this.i = i; // error
^" in i as{TypeError,ForNonNullableByDefault} core::int, super core::Object::•()
;
constructor constructor6({core::int? i = #C1}) → self::A
: self::A::i = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:22:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
: this.i = i; // error
^" in i as{TypeError,ForNonNullableByDefault} core::int, super core::Object::•()
;
constructor constructor7({required core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
external constructor constructor8([core::int i = #C1]) → self::A
: super core::Object::•()
;
external constructor constructor9({core::int i = #C1}) → self::A
: super core::Object::•()
;
static factory factory3([core::int i = #C1]) → self::A
let dynamic #redirecting_factory = self::A::constructor3 in invalid-expression;
static factory factory4({core::int i = #C1}) → self::A
let dynamic #redirecting_factory = self::A::constructor4 in invalid-expression;
static factory factory5([core::int? i = #C1]) → self::A
let dynamic #redirecting_factory = self::A::constructor5 in invalid-expression;
static factory factory6({core::int? i = #C1}) → self::A
let dynamic #redirecting_factory = self::A::constructor6 in invalid-expression;
static factory factory7({required core::int i = #C1}) → self::A
let dynamic #redirecting_factory = self::A::constructor7 in invalid-expression;
method method3([core::int i = #C1]) → dynamic {}
method method4({core::int i = #C1}) → dynamic {}
method method5([core::int? i = #C1]) → dynamic {}
method method6({core::int? i = #C1}) → dynamic {}
method method7({required core::int i = #C1}) → dynamic {}
external method method8([core::int i = #C1]) → dynamic;
external method method9({core::int i = #C1}) → dynamic;
}
abstract class B extends core::Object {
field core::int i = 42;
synthetic constructor •() → self::B
: super core::Object::•()
;
abstract method method3([core::int i = #C1]) → dynamic;
abstract method method4({core::int i = #C1}) → dynamic;
abstract method method5([core::int? i = #C1]) → dynamic;
abstract method method6({core::int? i = #C1}) → dynamic;
abstract method method7({required core::int i = #C1}) → dynamic;
}
class C extends core::Object implements self::B {
field core::int i;
static field dynamic _redirecting# = <dynamic>[self::C::factory3, self::C::factory4, self::C::factory5, self::C::factory6, self::C::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i = #C1]) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor2({core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor3([core::int i = #C1]) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor4({core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor5([core::int? i = #C1]) → self::C
: self::C::i = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:81:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
C.constructor5([int? i]) : this.i = i; // error
^" in i as{TypeError,ForNonNullableByDefault} core::int, super core::Object::•()
;
constructor constructor6({core::int? i = #C1}) → self::C
: self::C::i = let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:83:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
C.constructor6({int? i}) : this.i = i; // error
^" in i as{TypeError,ForNonNullableByDefault} core::int, super core::Object::•()
;
constructor constructor7({required core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
static factory factory3([core::int i = #C1]) → self::C
let dynamic #redirecting_factory = self::C::constructor3 in invalid-expression;
static factory factory4({core::int i = #C1}) → self::C
let dynamic #redirecting_factory = self::C::constructor4 in invalid-expression;
static factory factory5([core::int? i = #C1]) → self::C
let dynamic #redirecting_factory = self::C::constructor5 in invalid-expression;
static factory factory6({core::int? i = #C1}) → self::C
let dynamic #redirecting_factory = self::C::constructor6 in invalid-expression;
static factory factory7({required core::int i = #C1}) → self::C
let dynamic #redirecting_factory = self::C::constructor7 in invalid-expression;
method method3([core::int i = #C1]) → dynamic {}
method method4({core::int i = #C1}) → dynamic {}
method method5([core::int? i = #C1]) → dynamic {}
method method6({core::int? i = #C1}) → dynamic {}
method method7({required core::int i = #C1}) → dynamic {}
}
static method main() → void {}
constants {
#C1 = null
}

View file

@ -0,0 +1,183 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/issue42362.dart:41:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([int i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:43:16: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({int i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:8:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:10:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:12:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor3([int i]) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:15:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// A.constructor4({int i}) // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:98:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method3([i]) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:100:12: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// method4({i}) {} // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:73:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor1([this.i]); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:75:24: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor2({this.i}); // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:77:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor3([int i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:79:23: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// C.constructor4({int i}) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:19:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:22:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:81:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// C.constructor5([int? i]) : this.i = i; // error
// ^
//
// pkg/front_end/testcases/nnbd/issue42362.dart:83:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
// C.constructor6({int? i}) : this.i = i; // error
// ^
//
import self as self;
import "dart:core" as core;
class A extends core::Object {
final field core::int i;
static field dynamic _redirecting# = <dynamic>[self::A::factory3, self::A::factory4, self::A::factory5, self::A::factory6, self::A::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i = #C1]) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor2({core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor3([core::int i = #C1]) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor4({core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
constructor constructor5([core::int? i = #C1]) → self::A
: self::A::i = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:19:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
: this.i = i; // error
^" in i, super core::Object::•()
;
constructor constructor6({core::int? i = #C1}) → self::A
: self::A::i = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:22:18: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
: this.i = i; // error
^" in i, super core::Object::•()
;
constructor constructor7({required core::int i = #C1}) → self::A
: self::A::i = i, super core::Object::•()
;
external constructor constructor8([core::int i = #C1]) → self::A
: super core::Object::•()
;
external constructor constructor9({core::int i = #C1}) → self::A
: super core::Object::•()
;
static factory factory3([core::int i = #C1]) → self::A
let<BottomType> #redirecting_factory = self::A::constructor3 in invalid-expression;
static factory factory4({core::int i = #C1}) → self::A
let<BottomType> #redirecting_factory = self::A::constructor4 in invalid-expression;
static factory factory5([core::int? i = #C1]) → self::A
let<BottomType> #redirecting_factory = self::A::constructor5 in invalid-expression;
static factory factory6({core::int? i = #C1}) → self::A
let<BottomType> #redirecting_factory = self::A::constructor6 in invalid-expression;
static factory factory7({required core::int i = #C1}) → self::A
let<BottomType> #redirecting_factory = self::A::constructor7 in invalid-expression;
method method3([core::int i = #C1]) → dynamic {}
method method4({core::int i = #C1}) → dynamic {}
method method5([core::int? i = #C1]) → dynamic {}
method method6({core::int? i = #C1}) → dynamic {}
method method7({required core::int i = #C1}) → dynamic {}
external method method8([core::int i = #C1]) → dynamic;
external method method9({core::int i = #C1}) → dynamic;
}
abstract class B extends core::Object {
field core::int i = 42;
synthetic constructor •() → self::B
: super core::Object::•()
;
abstract method method3([core::int i = #C1]) → dynamic;
abstract method method4({core::int i = #C1}) → dynamic;
abstract method method5([core::int? i = #C1]) → dynamic;
abstract method method6({core::int? i = #C1}) → dynamic;
abstract method method7({required core::int i = #C1}) → dynamic;
}
class C extends core::Object implements self::B {
field core::int i;
static field dynamic _redirecting# = <dynamic>[self::C::factory3, self::C::factory4, self::C::factory5, self::C::factory6, self::C::factory7]/*isNullableByDefault*/;
constructor constructor1([core::int i = #C1]) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor2({core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor3([core::int i = #C1]) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor4({core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
constructor constructor5([core::int? i = #C1]) → self::C
: self::C::i = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:81:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
C.constructor5([int? i]) : this.i = i; // error
^" in i, super core::Object::•()
;
constructor constructor6({core::int? i = #C1}) → self::C
: self::C::i = let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/issue42362.dart:83:39: Error: A value of type 'int?' can't be assigned to a variable of type 'int'.
C.constructor6({int? i}) : this.i = i; // error
^" in i, super core::Object::•()
;
constructor constructor7({required core::int i = #C1}) → self::C
: self::C::i = i, super core::Object::•()
;
static factory factory3([core::int i = #C1]) → self::C
let<BottomType> #redirecting_factory = self::C::constructor3 in invalid-expression;
static factory factory4({core::int i = #C1}) → self::C
let<BottomType> #redirecting_factory = self::C::constructor4 in invalid-expression;
static factory factory5([core::int? i = #C1]) → self::C
let<BottomType> #redirecting_factory = self::C::constructor5 in invalid-expression;
static factory factory6({core::int? i = #C1}) → self::C
let<BottomType> #redirecting_factory = self::C::constructor6 in invalid-expression;
static factory factory7({required core::int i = #C1}) → self::C
let<BottomType> #redirecting_factory = self::C::constructor7 in invalid-expression;
method method3([core::int i = #C1]) → dynamic {}
method method4({core::int i = #C1}) → dynamic {}
method method5([core::int? i = #C1]) → dynamic {}
method method6({core::int? i = #C1}) → dynamic {}
method method7({required core::int i = #C1}) → dynamic {}
}
static method main() → void {}
constants {
#C1 = null
}

View file

@ -30,10 +30,6 @@ library /*isNonNullableByDefault*/;
// void method([int i]) {}
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:8:36: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// external void patchedMethod([int i]);
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:11:18: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// void method([int i]) {}
// ^

View file

@ -32,10 +32,6 @@ library /*isNonNullableByDefault*/;
// void method([int i]) {}
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:8:36: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// external void patchedMethod([int i]);
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:11:18: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// void method([int i]) {}
// ^

View file

@ -32,10 +32,6 @@ library /*isNonNullableByDefault*/;
// void method([int i]) {}
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:8:36: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// external void patchedMethod([int i]);
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:11:18: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// void method([int i]) {}
// ^

View file

@ -32,10 +32,6 @@ library /*isNonNullableByDefault*/;
// void method([int i]) {}
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:8:36: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// external void patchedMethod([int i]);
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:11:18: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// void method([int i]) {}
// ^

View file

@ -32,10 +32,6 @@ library /*isNonNullableByDefault*/;
// void method([int i]) {}
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:8:36: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// external void patchedMethod([int i]);
// ^
//
// pkg/front_end/testcases/nnbd/platform_optional_parameters/origin_lib.dart:11:18: Error: Optional parameter 'i' should have a default value because its type 'int' doesn't allow null.
// void method([int i]) {}
// ^

View file

@ -9,7 +9,7 @@ import 'dart:async';
import 'package:expect/expect.dart';
class W<T> {
final FutureOr<T> v;
final FutureOr<T>? v;
W({this.v});
@pragma('vm:never-inline')

View file

@ -8,7 +8,7 @@
library _js_annotations;
class JS {
final String name;
final String? name;
const JS([this.name]);
}

View file

@ -9,7 +9,7 @@ import "package:async_helper/async_helper.dart";
class Tracer {
final String expected;
final String name;
final String? name;
String _trace = "";
Tracer(this.expected, [this.name]);

View file

@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
// to other annotated types.
class Annotation {
final String value;
final String? value;
const Annotation({this.value});
}
@ -18,9 +18,9 @@ enum Enum {
}
class SubAnno extends Annotation {
final Enum e;
final Type type;
const SubAnno({String value, this.e, this.type}) : super(value: value);
final Enum? e;
final Type? type;
const SubAnno({String? value, this.e, this.type}) : super(value: value);
}
@SubAnno(value: 'super')