blob: 6e6083c2edc373cc301767abed59733dd157ac69 [file] [log] [blame]
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/null_aware2.dart:7:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
// static int staticField;
// ^^^^^^^^^^^
//
// pkg/front_end/testcases/general/null_aware2.dart:13:3: Warning: The class 'Foo' cannot be null.
// Try replacing '?.' with '.'
// Foo?.staticField = 5;
// ^^^
//
// pkg/front_end/testcases/general/null_aware2.dart:17:3: Warning: The class 'Foo' cannot be null.
// Try replacing '?.' with '.'
// Foo?.staticField ??= 5;
// ^^^
//
// pkg/front_end/testcases/general/null_aware2.dart:12:3: Warning: Operand of null-aware operation '?.' has type 'Foo' which excludes null.
// - 'Foo' is from 'pkg/front_end/testcases/general/null_aware2.dart'.
// foo?.field = 5;
// ^
//
// pkg/front_end/testcases/general/null_aware2.dart:14:7: Warning: Operand of null-aware operation '??=' has type 'int' which excludes null.
// foo.field ??= 5;
// ^
//
// pkg/front_end/testcases/general/null_aware2.dart:15:7: Warning: Operand of null-aware operation '??=' has type 'int' which excludes null.
// Foo.staticField ??= 5;
// ^
//
// pkg/front_end/testcases/general/null_aware2.dart:16:3: Warning: Operand of null-aware operation '?.' has type 'Foo' which excludes null.
// - 'Foo' is from 'pkg/front_end/testcases/general/null_aware2.dart'.
// foo?.field ??= 5;
// ^
//
// pkg/front_end/testcases/general/null_aware2.dart:17:8: Warning: Operand of null-aware operation '??=' has type 'int' which excludes null.
// Foo?.staticField ??= 5;
// ^
//
// pkg/front_end/testcases/general/null_aware2.dart:19:22: Warning: Operand of null-aware operation '??' has type 'int' which excludes null.
// int intValue = foo.field ?? 6;
// ^
//
// pkg/front_end/testcases/general/null_aware2.dart:20:22: Warning: Operand of null-aware operation '??' has type 'int' which excludes null.
// num numValue = foo.field ?? 4.5;
// ^
//
// pkg/front_end/testcases/general/null_aware2.dart:6:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
// int field;
// ^^^^^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
field core::int field = null;
static field core::int staticField = null;
synthetic constructor •() self::Foo
: super core::Object::•()
;
}
static method test() dynamic {
self::Foo foo = new self::Foo::•();
let final self::Foo #t1 = foo in #t1 == null ?{core::int?} null : #t1.{self::Foo::field} = 5;
self::Foo::staticField = 5;
let final self::Foo #t2 = foo in #t2.{self::Foo::field}{core::int} == null ?{core::int} #t2.{self::Foo::field} = 5 : null;
self::Foo::staticField == null ?{core::int} self::Foo::staticField = 5 : null;
let final self::Foo #t3 = foo in #t3 == null ?{core::int?} null : #t3.{self::Foo::field}{core::int} == null ?{core::int} #t3.{self::Foo::field} = 5 : null;
self::Foo::staticField == null ?{core::int} self::Foo::staticField = 5 : null;
core::int intValue = let final core::int #t4 = foo.{self::Foo::field}{core::int} in #t4 == null ?{core::int} 6 : #t4;
core::num numValue = let final core::int #t5 = foo.{self::Foo::field}{core::int} in #t5 == null ?{core::num} 4.5 : #t5;
}
static method main() dynamic {}