blob: ca860c8955fba79c3ebe78a9d9ffa50228968eba [file] [log] [blame]
library;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/nullable_access.dart:23:18: Warning: Property 'nonNullableField' is accessed on 'Class?' which 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 {
const constructor •() self::A
: super core::Object::•()
;
get nonNullableProperty() self::A
return this;
}
static method main() dynamic {
self::Class? c;
self::throws(() self::A => c.{self::Class::nonNullableField});
self::expect(null, let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::A?} null : #t1{self::Class}.{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::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 dynamic catch(final dynamic e) {
return;
}
throw "Expected throws.";
}
constants {
#C1 = self::A {}
}