7252a146a2
Closes #43278. Bug: https://github.com/dart-lang/sdk/issues/43278 Change-Id: I4b8a938441c75462a98a1d72d5fb23d50b5f92b0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162160 Commit-Queue: Dmitry Stefantsov <dmitryas@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
34 lines
739 B
Dart
34 lines
739 B
Dart
// 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 {
|
|
int? foo;
|
|
A bar;
|
|
|
|
A(this.bar);
|
|
}
|
|
|
|
test<T extends A?>(A? a, T t, dynamic d, int x) {
|
|
a.foo ??= x; // Error.
|
|
t.foo ??= x; // Error.
|
|
d.foo ??= x; // Ok.
|
|
a?.bar.foo ??= x; // Ok.
|
|
}
|
|
|
|
class B {}
|
|
|
|
extension Extension on B {
|
|
int? get fooExtension => null;
|
|
void set fooExtension(int? value) {}
|
|
B get barExtension => new B();
|
|
}
|
|
|
|
testExtension<T extends B?>(B? b, T t, int x) {
|
|
b.fooExtension ??= x; // Error.
|
|
t.fooExtension ??= x; // Error.
|
|
b?.barExtension.fooExtension ??= x; // Ok.
|
|
}
|
|
|
|
main() {}
|