Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 960620d

Browse files
author
Dart CI
committed
Version 2.12.0-86.0.dev
Merge commit 'b9541a14bbcd1c2b2276c0fa78d75a7da486739a' into 'dev'
2 parents 73e6f09 + b9541a1 commit 960620d

14 files changed

+224
-15
lines changed

pkg/front_end/lib/src/fasta/kernel/combined_member_signature.dart

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ abstract class CombinedMemberSignatureBase<T> {
8989

9090
bool _neededNnbdTopMerge = false;
9191

92+
bool _containsNnbdTypes = false;
93+
9294
bool _needsCovarianceMerging = false;
9395

9496
bool _isCombinedMemberSignatureCovarianceComputed = false;
@@ -222,6 +224,43 @@ abstract class CombinedMemberSignatureBase<T> {
222224
return _neededNnbdTopMerge;
223225
}
224226

227+
/// Returns `true` if the type of combined member signature has nnbd types.
228+
///
229+
/// If the combined member signature for an opt-in class is computed from
230+
/// identical legacy types, that is, without the need for nnbd top merge, then
231+
/// the type will be copied over directly and a member created from the
232+
/// combined member signature will therefore be a legacy member, even though
233+
/// it is declared in an opt in class.
234+
///
235+
/// To avoid reporting errors as if the member was an opt-in member, it is
236+
/// marked as nullable-by-default.
237+
///
238+
/// For instance
239+
///
240+
/// // opt out:
241+
/// mixin Mixin {
242+
/// void method({int named}) {}
243+
/// }
244+
/// // opt in:
245+
/// class Super {
246+
/// void method({required covariant int named}) {}
247+
/// }
248+
/// class Class extends Super with Mixin {
249+
/// // A forwarding stop for Mixin.method will be inserted here:
250+
/// // void method({covariant int named}) -> Mixin.method
251+
/// }
252+
/// class SubClass extends Class {
253+
/// // This is a valid override since `Class.method` should should
254+
/// // not be considered as _not_ having a required named parameter -
255+
/// // it is legacy and doesn't know about required named parameters.
256+
/// void method({required int named}) {}
257+
/// }
258+
///
259+
bool get containsNnbdTypes {
260+
_ensureCombinedMemberSignatureType();
261+
return _containsNnbdTypes;
262+
}
263+
225264
/// Returns `true` if the covariance of the combined member signature is
226265
/// different from the covariance of the overridden member in the superclass.
227266
///
@@ -283,6 +322,8 @@ abstract class CombinedMemberSignatureBase<T> {
283322
if (classBuilder.library.isNonNullableByDefault) {
284323
DartType canonicalMemberType =
285324
_combinedMemberSignatureType = getMemberType(_canonicalMemberIndex);
325+
_containsNnbdTypes =
326+
_getMember(_canonicalMemberIndex).isNonNullableByDefault;
286327
if (_mutualSubtypes != null) {
287328
_combinedMemberSignatureType =
288329
norm(_coreTypes, _combinedMemberSignatureType);
@@ -296,6 +337,7 @@ abstract class CombinedMemberSignatureBase<T> {
296337
}
297338
_neededNnbdTopMerge =
298339
canonicalMemberType != _combinedMemberSignatureType;
340+
_containsNnbdTypes = _neededNnbdTopMerge;
299341
}
300342
} else {
301343
_combinedMemberSignatureType = getMemberType(_canonicalMemberIndex);
@@ -486,8 +528,7 @@ abstract class CombinedMemberSignatureBase<T> {
486528
)
487529
..startFileOffset = startFileOffset
488530
..fileOffset = fileOffset
489-
..isNonNullableByDefault =
490-
enclosingClass.enclosingLibrary.isNonNullableByDefault
531+
..isNonNullableByDefault = containsNnbdTypes
491532
..parent = enclosingClass;
492533
}
493534

@@ -537,8 +578,7 @@ abstract class CombinedMemberSignatureBase<T> {
537578
reference: referenceFrom?.reference)
538579
..startFileOffset = startFileOffset
539580
..fileOffset = fileOffset
540-
..isNonNullableByDefault =
541-
enclosingClass.enclosingLibrary.isNonNullableByDefault
581+
..isNonNullableByDefault = containsNnbdTypes
542582
..parent = enclosingClass;
543583
}
544584

@@ -617,8 +657,7 @@ abstract class CombinedMemberSignatureBase<T> {
617657
reference: referenceFrom?.reference)
618658
..startFileOffset = startFileOffset
619659
..fileOffset = fileOffset
620-
..isNonNullableByDefault =
621-
enclosingClass.enclosingLibrary.isNonNullableByDefault
660+
..isNonNullableByDefault = containsNnbdTypes
622661
..parent = enclosingClass;
623662
}
624663

pkg/front_end/testcases/nnbd_mixed/flutter_issue_63029/flutter_issue_63029.dart.weak.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ abstract class _F&B&D = flu::B<self::E> with flu2::D<self::E> /*isAnonymousMixin
1616
synthetic constructor •() → self::_F&B&D
1717
: super flu::B::•()
1818
;
19-
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
19+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
2020
}
2121
class F extends self::_F&B&D {
2222
synthetic constructor •() → self::F

pkg/front_end/testcases/nnbd_mixed/inheritance_from_opt_out.dart.weak.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class Class4b extends core::Object implements inh::GenericInterface<core::num> {
3434
synthetic constructor •() → self::Class4b
3535
: super core::Object::•()
3636
;
37-
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
37+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
3838
}
3939
class Class4c extends core::Object implements inh::GenericInterface<core::num?> {
4040
synthetic constructor •() → self::Class4c
4141
: super core::Object::•()
4242
;
43-
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
43+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
4444
}
4545
class Class4d extends inh::LegacyClass4 implements inh::GenericInterface<core::num> {
4646
synthetic constructor •() → self::Class4d

pkg/front_end/testcases/nnbd_mixed/inheritance_from_opt_out.dart.weak.transformed.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class Class4b extends core::Object implements inh::GenericInterface<core::num> {
3434
synthetic constructor •() → self::Class4b
3535
: super core::Object::•()
3636
;
37-
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
37+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
3838
}
3939
class Class4c extends core::Object implements inh::GenericInterface<core::num?> {
4040
synthetic constructor •() → self::Class4c
4141
: super core::Object::•()
4242
;
43-
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
43+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
4444
}
4545
class Class4d extends inh::LegacyClass4 implements inh::GenericInterface<core::num> {
4646
synthetic constructor •() → self::Class4d

pkg/front_end/testcases/nnbd_mixed/mixin_from_opt_out.dart.weak.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ abstract class _Class&Object&Mixin = core::Object with mix::Mixin /*isAnonymousM
99
const synthetic constructor •() → self::_Class&Object&Mixin
1010
: super core::Object::•()
1111
;
12-
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
12+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
1313
}
1414
class Class extends self::_Class&Object&Mixin {
1515
synthetic constructor •() → self::Class

pkg/front_end/testcases/nnbd_mixed/required_name_override.dart.weak.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class A extends self::B implements req::C {
3636
method test_default({required core::int? i = #C1}) → void {}
3737
method test_nondefault({required core::int? i = #C1}) → void {}
3838
method test_legacy({required core::int? i = #C1}) → void {}
39-
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
39+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
4040
}
4141
static method main() → dynamic {
4242
new self::A::•().{self::A::test_default}(i: 1);

pkg/front_end/testcases/nnbd_mixed/required_name_override.dart.weak.transformed.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class A extends self::B implements req::C {
3636
method test_default({required core::int? i = #C1}) → void {}
3737
method test_nondefault({required core::int? i = #C1}) → void {}
3838
method test_legacy({required core::int? i = #C1}) → void {}
39-
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
39+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
4040
}
4141
static method main() → dynamic {
4242
new self::A::•().{self::A::test_default}(i: 1);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'required_parameter_mixed_from_opt_out_lib.dart';
6+
7+
class Super {
8+
void method({required covariant int named}) {}
9+
}
10+
11+
class Class extends Super with Mixin {}
12+
13+
class SubClass extends Class {
14+
void method({required covariant int named}) {}
15+
}
16+
17+
main() {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'required_parameter_mixed_from_opt_out_lib.dart';
2+
3+
class Super {
4+
void method({required covariant int named}) {}
5+
}
6+
7+
class Class extends Super with Mixin {}
8+
9+
class SubClass extends Class {
10+
void method({required covariant int named}) {}
11+
}
12+
13+
main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'required_parameter_mixed_from_opt_out_lib.dart';
2+
3+
class Class extends Super with Mixin {}
4+
5+
class SubClass extends Class {
6+
void method({required covariant int named}) {}
7+
}
8+
9+
class Super {
10+
void method({required covariant int named}) {}
11+
}
12+
13+
main() {}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
import "required_parameter_mixed_from_opt_out_lib.dart" as req;
5+
6+
import "org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart";
7+
8+
class Super extends core::Object {
9+
synthetic constructor •() → self::Super
10+
: super core::Object::•()
11+
;
12+
method method({required covariant core::int named = #C1}) → void {}
13+
}
14+
abstract class _Class&Super&Mixin = self::Super with req::Mixin /*isAnonymousMixin*/ {
15+
synthetic constructor •() → self::_Class&Super&Mixin
16+
: super self::Super::•()
17+
;
18+
forwarding-stub method /*isNullableByDefault*/ method({covariant core::int* named = #C1}) → void
19+
return super.{self::Super::method}(named: named);
20+
abstract member-signature operator /*isNullableByDefault*/ ==(dynamic other) → core::bool*; -> core::Object::==
21+
}
22+
class Class extends self::_Class&Super&Mixin {
23+
synthetic constructor •() → self::Class
24+
: super self::_Class&Super&Mixin::•()
25+
;
26+
}
27+
class SubClass extends self::Class {
28+
synthetic constructor •() → self::SubClass
29+
: super self::Class::•()
30+
;
31+
method method({required covariant core::int named = #C1}) → void {}
32+
}
33+
static method main() → dynamic {}
34+
35+
library;
36+
import self as req;
37+
import "dart:core" as core;
38+
39+
abstract class Mixin extends core::Object /*isMixinDeclaration*/ {
40+
method method({core::int* named = #C1}) → void {}
41+
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
42+
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
43+
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
44+
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
45+
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
46+
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
47+
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
48+
abstract member-signature method toString() → core::String*; -> core::Object::toString
49+
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
50+
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
51+
}
52+
53+
constants {
54+
#C1 = null
55+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
import "required_parameter_mixed_from_opt_out_lib.dart" as req;
5+
6+
import "org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart";
7+
8+
class Super extends core::Object {
9+
synthetic constructor •() → self::Super
10+
: super core::Object::•()
11+
;
12+
method method({required covariant core::int named = #C1}) → void {}
13+
}
14+
abstract class _Class&Super&Mixin extends self::Super implements req::Mixin /*isAnonymousMixin,isEliminatedMixin*/ {
15+
synthetic constructor •() → self::_Class&Super&Mixin
16+
: super self::Super::•()
17+
;
18+
method /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ method({covariant core::int* named = #C1}) → void {}
19+
abstract member-signature operator /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ ==(dynamic other) → core::bool*; -> core::Object::==
20+
abstract member-signature get /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ _identityHashCode() → core::int*; -> core::Object::_identityHashCode
21+
abstract member-signature method /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
22+
abstract member-signature method /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
23+
abstract member-signature method /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
24+
abstract member-signature method /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
25+
abstract member-signature get /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ hashCode() → core::int*; -> core::Object::hashCode
26+
abstract member-signature method /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ toString() → core::String*; -> core::Object::toString
27+
abstract member-signature method /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
28+
abstract member-signature get /*isNullableByDefault, from org-dartlang-testcase:///required_parameter_mixed_from_opt_out_lib.dart */ runtimeType() → core::Type*; -> core::Object::runtimeType
29+
}
30+
class Class extends self::_Class&Super&Mixin {
31+
synthetic constructor •() → self::Class
32+
: super self::_Class&Super&Mixin::•()
33+
;
34+
}
35+
class SubClass extends self::Class {
36+
synthetic constructor •() → self::SubClass
37+
: super self::Class::•()
38+
;
39+
method method({required covariant core::int named = #C1}) → void {}
40+
}
41+
static method main() → dynamic {}
42+
43+
library;
44+
import self as req;
45+
import "dart:core" as core;
46+
47+
abstract class Mixin extends core::Object /*isMixinDeclaration*/ {
48+
method method({core::int* named = #C1}) → void {}
49+
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
50+
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
51+
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
52+
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
53+
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
54+
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
55+
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
56+
abstract member-signature method toString() → core::String*; -> core::Object::toString
57+
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
58+
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
59+
}
60+
61+
constants {
62+
#C1 = null
63+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// @dart=2.9
6+
7+
mixin Mixin {
8+
void method({int named}) {}
9+
}

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 12
2929
PATCH 0
30-
PRERELEASE 85
30+
PRERELEASE 86
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)