// 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 { late T x; } class B { T? _y; T? get y => _y; set y(T? val) { _y = val; } } main() { A a = new A(); expect(42, a.x = 42); throws(() => a.x = 0.5); B b = new B(); 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"; }