Files
sdk/pkg/front_end/testcases/late_lowering/issue42407.dart
T
Johnni Winther bcace93c4f [cfe] Add test for issue 42407
Change-Id: Idf4362be94d42f36afa4e7a471e412a8f3b00c0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151821
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-06-19 14:50:05 +00:00

39 lines
701 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<T> {
late T x;
}
class B<T> {
T? _y;
T? get y => _y;
set y(T? val) {
_y = val;
}
}
main() {
A<num> a = new A<int>();
expect(42, a.x = 42);
throws(() => a.x = 0.5);
B<num> b = new B<int>();
expect(42, b.y = 42);
throws(() => b.y = 0.5);
}
expect(expected, actual) {
if (expected != actual) throw "Expected $expected, actual $actual";
}
throws(void Function() f) {
try {
f();
} catch (_) {
return;
}
throw "Expected exception";
}