Files
sdk/tests/compiler/dart2js/inference/data/non_null.dart
T
Johnni Winther 1c673b1046 Include bounds in type literals
Change-Id: Ieb3e5b09e88c98f8943a6e7ca9031c8a6ab776e1
Reviewed-on: https://dart-review.googlesource.com/63820
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-07-09 12:24:04 +00:00

53 lines
1.3 KiB
Dart

// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/*element: main:[null]*/
main() {
nonNullStaticField();
nonNullInstanceField1();
nonNullInstanceField2();
nonNullLocal();
}
/*element: staticField:[null|exact=JSUInt31]*/
var staticField;
/*element: nonNullStaticField:[exact=JSUInt31]*/
nonNullStaticField() => staticField ??= 42;
/*element: Class1.:[exact=Class1]*/
class Class1 {
/*element: Class1.field:[null|exact=JSUInt31]*/
var field;
}
/*element: nonNullInstanceField1:[exact=JSUInt31]*/
nonNullInstanceField1() {
return new Class1(). /*[exact=Class1]*/ /*update: [exact=Class1]*/ field ??=
42;
}
/*element: Class2.:[exact=Class2]*/
class Class2 {
/*element: Class2.field:[null|exact=JSUInt31]*/
var field;
/*element: Class2.method:[exact=JSUInt31]*/
method() {
return /*[exact=Class2]*/ /*update: [exact=Class2]*/ field ??= 42;
}
}
/*element: nonNullInstanceField2:[exact=JSUInt31]*/
nonNullInstanceField2() {
return new Class2(). /*invoke: [exact=Class2]*/ method();
}
// TODO(johnniwinther): We should infer that the returned value cannot be null.
/*element: nonNullLocal:[null|exact=JSUInt31]*/
nonNullLocal() {
var local = null;
return local ??= 42;
}