blob: 40de06c3aa4706d041c3ed61a95cd042590888fd [file] [log] [blame]
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/nullable_access.dart:23:18: Error: Property 'nonNullableField' cannot be accessed on 'Class?' because it is potentially null.
// - 'Class' is from 'pkg/front_end/testcases/nnbd/nullable_access.dart'.
// Try accessing using ?. instead.
// throws(() => c.nonNullableField);
// ^^^^^^^^^^^^^^^^
//
import self as self;
import "dart:core" as core;
class Class extends core::Object {
field self::A nonNullableField = #C1;
synthetic constructor •() self::Class
: super core::Object::•()
;
get nonNullableProperty() self::A
return this.{self::Class::nonNullableField};
set nonNullableProperty(self::A value) void {
this.{self::Class::nonNullableField} = value;
}
method nonNullableMethod() self::A
return this.{self::Class::nonNullableField};
}
class A extends core::Object /*hasConstConstructor*/ {
const constructor •() self::A
: super core::Object::•()
;
get nonNullableProperty() self::A
return this;
}
static method main() dynamic {
self::Class? c;
self::throws(() void => let final Never #t1 = invalid-expression "pkg/front_end/testcases/nnbd/nullable_access.dart:23:18: Error: Property 'nonNullableField' cannot be accessed on 'Class?' because it is potentially null.
- 'Class' is from 'pkg/front_end/testcases/nnbd/nullable_access.dart'.
Try accessing using ?. instead.
throws(() => c.nonNullableField);
^^^^^^^^^^^^^^^^" in c.{self::Class::nonNullableField});
self::expect(null, let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::A?} null : #t2{self::Class}.{self::Class::nonNullableField});
self::expect(null, let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::A?} null : #t3{self::Class}.{self::Class::nonNullableField}.{self::A::nonNullableProperty});
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!expected.{core::Object::==}(actual))
throw "Expected ${expected}, actual ${actual}";
}
static method throws(() → void f) → dynamic {
try {
f.call();
}
on core::Object catch(final core::Object e) {
return;
}
throw "Expected throws.";
}
constants {
#C1 = self::A {}
}
Constructor coverage from constants:
org-dartlang-testcase:///nullable_access.dart:
- A. (from org-dartlang-testcase:///nullable_access.dart:16:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)