| library /*isNonNullableByDefault*/; |
| import self as self; |
| import "dart:core" as core; |
| import "dart:_internal" as _in; |
| |
| static method main() → dynamic { |
| lowered core::int? #lateLocal; |
| function #lateLocal#get() → core::int |
| return let final core::int? #t1 = #lateLocal in #t1.==(null) ?{core::int} throw new _in::LateError::localNI("lateLocal") : #t1{core::int}; |
| function #lateLocal#set(core::int #t2) → dynamic |
| return #lateLocal = #t2; |
| self::throws(() → core::int => #lateLocal#get.call(), "Read value from uninitialized lateLocal"); |
| self::expect(123, #lateLocal#set.call(123)); |
| self::expect(123, #lateLocal#get.call()); |
| function local<T extends core::Object? = dynamic>(T% value) → Null { |
| lowered T? #lateGenericLocal; |
| lowered core::bool #lateGenericLocal#isSet = false; |
| function #lateGenericLocal#get() → T% |
| return #lateGenericLocal#isSet ?{T%} #lateGenericLocal{T%} : throw new _in::LateError::localNI("lateGenericLocal"); |
| function #lateGenericLocal#set(T% #t3) → dynamic { |
| #lateGenericLocal#isSet = true; |
| return #lateGenericLocal = #t3; |
| } |
| self::throws(() → T% => #lateGenericLocal#get.call(), "Read value from uninitialized lateGenericLocal"); |
| self::expect(value, #lateGenericLocal#set.call(value)); |
| self::expect(value, #lateGenericLocal#get.call()); |
| } |
| local.call<core::int?>(null); |
| local.call<core::int?>(0); |
| local.call<core::int>(0); |
| } |
| static method expect(dynamic expected, dynamic actual) → dynamic { |
| if(!expected.{core::Object::==}(actual)) |
| throw "Expected ${expected}, actual ${actual}"; |
| } |
| static method throws(() → dynamic f, core::String message) → dynamic { |
| dynamic value; |
| try { |
| value = f.call(); |
| } |
| on core::Error catch(final core::Error e) { |
| core::print(e); |
| return; |
| } |
| throw "${message}: ${value}"; |
| } |