a577d0aea5
Change-Id: I3670e77a205404c0b35ee551a18c6ebdc2ecab33 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128069 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
40 lines
863 B
Dart
40 lines
863 B
Dart
// Copyright (c) 2019, 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 Class {
|
|
A nonNullableField = const A();
|
|
A get nonNullableProperty => nonNullableField;
|
|
void set nonNullableProperty(A value) {
|
|
nonNullableField = value;
|
|
}
|
|
|
|
A nonNullableMethod() => nonNullableField;
|
|
}
|
|
|
|
class A {
|
|
const A();
|
|
|
|
A get nonNullableProperty => this;
|
|
}
|
|
|
|
main() {
|
|
Class? c;
|
|
throws(() => c.nonNullableField);
|
|
expect(null, c?.nonNullableField);
|
|
expect(null, c?.nonNullableField.nonNullableProperty);
|
|
}
|
|
|
|
expect(expected, actual) {
|
|
if (expected != actual) throw 'Expected $expected, actual $actual';
|
|
}
|
|
|
|
throws(void Function() f) {
|
|
try {
|
|
f();
|
|
} catch (e) {
|
|
return;
|
|
}
|
|
throw 'Expected throws.';
|
|
}
|