Files
sdk/tests/compiler/dart2js/inference/data/fields.dart
T
Johnni Winther 81a81c93eb Handle instance field initialization in inferrer
This normalizes `var field = null;` and `var field;` to `var field;` for
both the AST- and IR-based inferences.

Change-Id: I753637c130a9f44ed01d18946c234353048f8971
Reviewed-on: https://dart-review.googlesource.com/6480
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-09-21 08:46:22 +00:00

64 lines
2.0 KiB
Dart

// Copyright (c) 2017, 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() {
fieldGetUnset();
fieldGetUnsetInitialized();
fieldSet();
fieldSetReturn();
}
////////////////////////////////////////////////////////////////////////////////
/// Get an uninitialized field.
////////////////////////////////////////////////////////////////////////////////
/*element: Class1.:[exact=Class1]*/
class Class1 {
var /*element: Class1.field:[null]*/ field;
}
/*element: fieldGetUnset:[null]*/
fieldGetUnset() => new Class1(). /*[exact=Class1]*/ field;
////////////////////////////////////////////////////////////////////////////////
/// Get a field initialized to `null`.
////////////////////////////////////////////////////////////////////////////////
/*element: Class4.:[exact=Class4]*/
class Class4 {
var /*element: Class4.field:[null]*/ field = null;
}
/*element: fieldGetUnsetInitialized:[null]*/
fieldGetUnsetInitialized() => new Class4(). /*[exact=Class4]*/ field;
////////////////////////////////////////////////////////////////////////////////
/// Set an uninitialized field.
////////////////////////////////////////////////////////////////////////////////
/*element: Class2.:[exact=Class2]*/
class Class2 {
var /*element: Class2.field:[null|exact=JSUInt31]*/ field;
}
/*element: fieldSet:[null]*/
fieldSet() {
new Class2(). /*update: [exact=Class2]*/ field = 0;
}
////////////////////////////////////////////////////////////////////////////////
/// Return the setting of an uninitialized field.
////////////////////////////////////////////////////////////////////////////////
/*element: Class3.:[exact=Class3]*/
class Class3 {
var /*element: Class3.field:[null|exact=JSUInt31]*/ field;
}
/*element: fieldSetReturn:[exact=JSUInt31]*/
fieldSetReturn() {
return new Class3(). /*update: [exact=Class3]*/ field = 0;
}