| library /*isNonNullableByDefault*/; |
| import self as self; |
| import "dart:core" as core; |
| import "dart:_internal" as _in; |
| |
| class Class extends core::Object { |
| field core::int? _#Class#field = null; |
| field core::bool _#Class#field#isSet = false; |
| constructor constructor1() → self::Class |
| : super core::Object::•() |
| ; |
| constructor constructor2(core::int field) → self::Class |
| : self::Class::_#Class#field#isSet = true, self::Class::_#Class#field = field, super core::Object::•() |
| ; |
| constructor constructor3(core::int value) → self::Class |
| : self::Class::_#Class#field#isSet = true, self::Class::_#Class#field = value.{core::num::+}(1), super core::Object::•() |
| ; |
| constructor constructor4([core::int field = #C1]) → self::Class |
| : self::Class::_#Class#field#isSet = true, self::Class::_#Class#field = field, super core::Object::•() |
| ; |
| get field() → core::int |
| return this.{self::Class::_#Class#field#isSet} ?{core::int} let final core::int? #t1 = this.{self::Class::_#Class#field} in #t1{core::int} : throw new _in::LateError::fieldNI("field"); |
| set field(core::int #t2) → void |
| if(this.{self::Class::_#Class#field#isSet}) |
| throw new _in::LateError::fieldAI("field"); |
| else { |
| this.{self::Class::_#Class#field#isSet} = true; |
| this.{self::Class::_#Class#field} = #t2; |
| } |
| } |
| class Subclass extends self::Class { |
| constructor constructor1() → self::Subclass |
| : super self::Class::constructor1() |
| ; |
| constructor constructor2(core::int value) → self::Subclass |
| : super self::Class::constructor2(value) |
| ; |
| constructor constructor3(core::int value) → self::Subclass |
| : super self::Class::constructor3(value) |
| ; |
| constructor constructor4([core::int value = #C2]) → self::Subclass |
| : super self::Class::constructor4(value) |
| ; |
| } |
| static method test1() → dynamic { |
| self::Class c1 = new self::Class::constructor1(); |
| self::throws(() → core::int => c1.{self::Class::field}, "Read value from uninitialized Class.field"); |
| c1.{self::Class::field} = 16; |
| self::expect(16, c1.{self::Class::field}); |
| self::throws(() → core::int => c1.{self::Class::field} = 17, "Write value to initialized Class.field"); |
| self::Class c2 = new self::Class::constructor2(42); |
| self::expect(42, c2.{self::Class::field}); |
| self::throws(() → core::int => c2.{self::Class::field} = 43, "Write value to initialized Class.field"); |
| self::Class c3 = new self::Class::constructor3(87); |
| self::expect(88, c3.{self::Class::field}); |
| self::throws(() → core::int => c3.{self::Class::field} = 89, "Write value to initialized Class.field"); |
| self::Class c4 = new self::Class::constructor4(); |
| self::expect(42, c4.{self::Class::field}); |
| self::throws(() → core::int => c4.{self::Class::field} = 43, "Write value to initialized Class.field"); |
| self::Class c5 = new self::Class::constructor4(123); |
| self::expect(123, c5.{self::Class::field}); |
| self::throws(() → core::int => c5.{self::Class::field} = 124, "Write value to initialized Class.field"); |
| self::Class c6 = new self::Class::constructor1(); |
| c6.{self::Class::field} = 32; |
| self::expect(32, c6.{self::Class::field}); |
| self::throws(() → core::int => c6.{self::Class::field} = 32, "Write value to initialized Class.field"); |
| } |
| static method test2() → dynamic { |
| self::Subclass c1 = new self::Subclass::constructor1(); |
| self::throws(() → core::int => c1.{self::Class::field}, "Read value from uninitialized Class1.field"); |
| c1.{self::Class::field} = 16; |
| self::expect(16, c1.{self::Class::field}); |
| self::throws(() → core::int => c1.{self::Class::field} = 17, "Write value to initialized Class.field"); |
| self::Subclass c2 = new self::Subclass::constructor2(42); |
| self::expect(42, c2.{self::Class::field}); |
| self::throws(() → core::int => c2.{self::Class::field} = 43, "Write value to initialized Class.field"); |
| self::Subclass c3 = new self::Subclass::constructor3(87); |
| self::expect(88, c3.{self::Class::field}); |
| self::throws(() → core::int => c3.{self::Class::field} = 89, "Write value to initialized Class.field"); |
| self::Subclass c4 = new self::Subclass::constructor4(); |
| self::expect(87, c4.{self::Class::field}); |
| self::throws(() → core::int => c4.{self::Class::field} = 88, "Write value to initialized Class.field"); |
| self::Subclass c5 = new self::Subclass::constructor4(123); |
| self::expect(123, c5.{self::Class::field}); |
| self::throws(() → core::int => c5.{self::Class::field} = 124, "Write value to initialized Class.field"); |
| self::Subclass c6 = new self::Subclass::constructor1(); |
| c6.{self::Class::field} = 32; |
| self::expect(32, c6.{self::Class::field}); |
| self::throws(() → core::int => c6.{self::Class::field} = 32, "Write value to initialized Class.field"); |
| } |
| static method main() → dynamic { |
| self::test1(); |
| self::test2(); |
| } |
| 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}"; |
| } |
| |
| constants { |
| #C1 = 42 |
| #C2 = 87 |
| } |