Version 2.13.0-205.0.dev
Merge commit '61747ae4d39311d889a8fdef6811c4a2af577386' into 'dev'
diff --git a/pkg/dev_compiler/lib/src/kernel/property_model.dart b/pkg/dev_compiler/lib/src/kernel/property_model.dart
index 5e403c2..fc403b3 100644
--- a/pkg/dev_compiler/lib/src/kernel/property_model.dart
+++ b/pkg/dev_compiler/lib/src/kernel/property_model.dart
@@ -46,20 +46,35 @@
/// Private classes that can be extended outside of this library.
///
/// Normally private classes cannot be accessed outside this library, however,
- /// this can happen if they are extended by a public class, for example:
+ /// this can happen if they are extended by a public class or exposed by a
+ /// public typedef, for example:
///
/// class _A { int x = 42; }
/// class _B { int x = 42; }
+ /// class _C { int x = 42; }
///
- /// // _A is now effectively public for the purpose of overrides.
- /// class C extends _A {}
+ /// // _A and _B are now effectively public for the purpose of overrides.
+ /// class D extends _A {}
+ /// typedef E = _B;
///
- /// The class _A must treat is "x" as virtual, however _B does not.
+ /// The classes _A and _B must treat is "x" as virtual, however _C does not.
final _extensiblePrivateClasses = HashSet<Class>();
_LibraryVirtualFieldModel.build(Library library) {
var allClasses = library.classes;
+ for (var typedef in library.typedefs) {
+ // Ignore private typedefs.
+ if (typedef.name.startsWith('_')) continue;
+
+ var type = typedef.type;
+ if (type is InterfaceType && type.classNode.name.startsWith('_')) {
+ // Public typedefs of private classes expose those classes for
+ // extension.
+ _extensiblePrivateClasses.add(type.classNode);
+ }
+ }
+
// The set of public types is our initial extensible type set.
// From there, visit all immediate private types in this library, and so on
// from those private types, marking them as extensible.
diff --git a/tests/language/why_not_promoted/argument_type_not_assignable_nullability_error_test.dart b/tests/language/why_not_promoted/argument_type_not_assignable_nullability_error_test.dart
index cfde735..c4f6955 100644
--- a/tests/language/why_not_promoted/argument_type_not_assignable_nullability_error_test.dart
+++ b/tests/language/why_not_promoted/argument_type_not_assignable_nullability_error_test.dart
@@ -8,8 +8,9 @@
class C1 {
int? bad;
- // ^
- // [context 1] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 29] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 47] 'bad' refers to a property so it couldn't be promoted.
f(int i) {}
}
@@ -17,15 +18,16 @@
if (c.bad == null) return;
c.f(c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 29] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 1] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 47] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
}
class C2 {
int? bad;
- // ^
- // [context 2] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 38] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 48] 'bad' refers to a property so it couldn't be promoted.
f([int i = 0]) {}
}
@@ -33,15 +35,16 @@
if (c.bad == null) return;
c.f(c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 38] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 2] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 48] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
}
class C3 {
int? bad;
- // ^
- // [context 3] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 6] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 49] 'bad' refers to a property so it couldn't be promoted.
f({required int i}) {}
}
@@ -49,15 +52,16 @@
if (c.bad == null) return;
c.f(i: c.bad);
// ^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 6] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 3] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 49] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
}
class C4 {
int? bad;
- // ^
- // [context 4] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 16] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 50] 'bad' refers to a property so it couldn't be promoted.
f({int i = 0}) {}
}
@@ -65,15 +69,16 @@
if (c.bad == null) return;
c.f(i: c.bad);
// ^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 16] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 4] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 50] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
}
class C5 {
List<int>? bad;
- // ^
- // [context 5] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 33] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 51] 'bad' refers to a property so it couldn't be promoted.
f<T>(List<T> x) {}
}
@@ -81,15 +86,16 @@
if (c.bad == null) return;
c.f(c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 33] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 5] The argument type 'List<int>?' can't be assigned to the parameter type 'List<int>' because 'List<int>?' is nullable and 'List<int>' isn't.
+ // [cfe 51] The argument type 'List<int>?' can't be assigned to the parameter type 'List<int>' because 'List<int>?' is nullable and 'List<int>' isn't.
}
class C6 {
int? bad;
- // ^
- // [context 6] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 21] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 52] 'bad' refers to a property so it couldn't be promoted.
C6(int i);
}
@@ -97,15 +103,16 @@
if (c.bad == null) return null;
return C6(c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 21] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 6] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 52] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
}
class C7 {
int? bad;
- // ^
- // [context 7] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 42] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 53] 'bad' refers to a property so it couldn't be promoted.
C7(int i);
}
@@ -113,24 +120,25 @@
if (c.bad == null) return null;
return new C7(c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 42] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 7] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 53] The argument type 'int?' can't be assigned to the parameter type 'int' because 'int?' is nullable and 'int' isn't.
}
class C8 {
int? bad;
- // ^
- // [context 8] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 13] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 54] 'bad' refers to a property so it couldn't be promoted.
}
userDefinableBinaryOpRhs(C8 c) {
if (c.bad == null) return;
1 + c.bad;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 13] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 8] A value of type 'int?' can't be assigned to a variable of type 'num' because 'int?' is nullable and 'num' isn't.
+ // [cfe 54] A value of type 'int?' can't be assigned to a variable of type 'num' because 'int?' is nullable and 'num' isn't.
}
class C9 {
@@ -171,9 +179,11 @@
class C11 {
bool? bad;
- // ^
- // [context 9] 'bad' refers to a property so it couldn't be promoted.
- // [context 10] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 30] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 46] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 55] 'bad' refers to a property so it couldn't be promoted.
+ // [context 56] 'bad' refers to a property so it couldn't be promoted.
f(bool b) {}
}
@@ -181,21 +191,23 @@
if (c.bad == null) return;
c.f(c.bad && b);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 46] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 9] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 55] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
c.f(b && c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 30] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 10] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 56] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C12 {
bool? bad;
- // ^
- // [context 11] 'bad' refers to a property so it couldn't be promoted.
- // [context 12] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 27] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 36] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 57] 'bad' refers to a property so it couldn't be promoted.
+ // [context 58] 'bad' refers to a property so it couldn't be promoted.
f(bool b) {}
}
@@ -203,48 +215,51 @@
if (c.bad == null) return;
c.f(c.bad || b);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 27] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 11] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 57] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
c.f(b || c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 36] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 12] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 58] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C13 {
bool? bad;
- // ^
- // [context 13] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 40] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 59] 'bad' refers to a property so it couldn't be promoted.
}
assertStatementCondition(C13 c) {
if (c.bad == null) return;
assert(c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 40] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 13] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 59] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C14 {
bool? bad;
- // ^
- // [context 14] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 1] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 60] 'bad' refers to a property so it couldn't be promoted.
C14.assertInitializerCondition(C14 c)
: bad = c.bad!,
assert(c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 14] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 60] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C15 {
bool? bad;
- // ^
- // [context 15] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 28] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 61] 'bad' refers to a property so it couldn't be promoted.
f(bool b) {}
}
@@ -252,48 +267,53 @@
if (c.bad == null) return;
c.f(!c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 28] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 15] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 61] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C16 {
bool? bad;
- // ^
- // [context 16] 'bad' refers to a property so it couldn't be promoted.
- // [context 17] 'bad' refers to a property so it couldn't be promoted.
- // [context 18] 'bad' refers to a property so it couldn't be promoted.
- // [context 19] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 22] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 24] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 25] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 32] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 62] 'bad' refers to a property so it couldn't be promoted.
+ // [context 63] 'bad' refers to a property so it couldn't be promoted.
+ // [context 64] 'bad' refers to a property so it couldn't be promoted.
+ // [context 65] 'bad' refers to a property so it couldn't be promoted.
}
forLoopCondition(C16 c) {
if (c.bad == null) return;
for (; c.bad;) {}
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 32] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 16] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 62] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
[for (; c.bad;) null];
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 25] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 17] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 63] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
({for (; c.bad;) null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 22] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 18] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 64] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
({for (; c.bad;) null: null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 24] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 19] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 65] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C17 {
bool? bad;
- // ^
- // [context 20] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 10] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 66] 'bad' refers to a property so it couldn't be promoted.
f(int i) {}
}
@@ -301,189 +321,207 @@
if (c.bad == null) return;
c.f(c.bad ? 1 : 2);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 10] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 20] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 66] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C18 {
bool? bad;
- // ^
- // [context 21] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 26] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 67] 'bad' refers to a property so it couldn't be promoted.
}
doLoopCondition(C18 c) {
if (c.bad == null) return;
do {} while (c.bad);
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 26] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 21] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 67] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C19 {
bool? bad;
- // ^
- // [context 22] 'bad' refers to a property so it couldn't be promoted.
- // [context 23] 'bad' refers to a property so it couldn't be promoted.
- // [context 24] 'bad' refers to a property so it couldn't be promoted.
- // [context 25] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 5] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 9] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 12] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 39] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 68] 'bad' refers to a property so it couldn't be promoted.
+ // [context 69] 'bad' refers to a property so it couldn't be promoted.
+ // [context 70] 'bad' refers to a property so it couldn't be promoted.
+ // [context 71] 'bad' refers to a property so it couldn't be promoted.
}
ifCondition(C19 c) {
if (c.bad == null) return;
if (c.bad) {}
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 22] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 68] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
[if (c.bad) null];
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 12] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 23] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 69] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
({if (c.bad) null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 9] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 24] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 70] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
({if (c.bad) null: null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 39] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 25] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 71] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C20 {
bool? bad;
- // ^
- // [context 26] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 3] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 72] 'bad' refers to a property so it couldn't be promoted.
}
whileCondition(C20 c) {
if (c.bad == null) return;
while (c.bad) {}
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 26] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
+ // [cfe 72] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
}
class C21 {
int? bad;
- // ^
- // [context 27] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 17] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 73] 'bad' refers to a property so it couldn't be promoted.
}
assignmentRhs(C21 c, int i) {
if (c.bad == null) return;
i = c.bad;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 17] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 27] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 73] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C22 {
int? bad;
- // ^
- // [context 28] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 18] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 74] 'bad' refers to a property so it couldn't be promoted.
}
variableInitializer(C22 c) {
if (c.bad == null) return;
int i = c.bad;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 18] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 28] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 74] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C23 {
int? bad;
- // ^
- // [context 29] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 20] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 75] 'bad' refers to a property so it couldn't be promoted.
final int x;
final int y;
C23.constructorInitializer(C23 c)
: x = c.bad!,
y = c.bad;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [analyzer 20] COMPILE_TIME_ERROR.FIELD_INITIALIZER_NOT_ASSIGNABLE
// ^
- // [cfe 29] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 75] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C24 {
int? bad;
- // ^
- // [context 30] 'bad' refers to a property so it couldn't be promoted.
- // [context 31] 'bad' refers to a property so it couldn't be promoted.
- // [context 32] 'bad' refers to a property so it couldn't be promoted.
- // [context 33] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 14] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 41] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 43] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 44] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 76] 'bad' refers to a property so it couldn't be promoted.
+ // [context 77] 'bad' refers to a property so it couldn't be promoted.
+ // [context 78] 'bad' refers to a property so it couldn't be promoted.
+ // [context 79] 'bad' refers to a property so it couldn't be promoted.
}
forVariableInitializer(C24 c) {
if (c.bad == null) return;
for (int i = c.bad; false;) {}
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 44] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 30] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 76] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
[for (int i = c.bad; false;) null];
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 43] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 31] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 77] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
({for (int i = c.bad; false;) null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 41] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 32] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 78] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
({for (int i = c.bad; false;) null: null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 14] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 33] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 79] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C25 {
int? bad;
- // ^
- // [context 34] 'bad' refers to a property so it couldn't be promoted.
- // [context 35] 'bad' refers to a property so it couldn't be promoted.
- // [context 36] 'bad' refers to a property so it couldn't be promoted.
- // [context 37] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 2] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 4] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 8] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 11] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 80] 'bad' refers to a property so it couldn't be promoted.
+ // [context 81] 'bad' refers to a property so it couldn't be promoted.
+ // [context 82] 'bad' refers to a property so it couldn't be promoted.
+ // [context 83] 'bad' refers to a property so it couldn't be promoted.
}
forAssignmentInitializer(C25 c, int i) {
if (c.bad == null) return;
for (i = c.bad; false;) {}
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 2] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 34] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 80] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
[for (i = c.bad; false;) null];
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 4] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 35] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 81] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
({for (i = c.bad; false;) null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 11] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 36] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 82] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
({for (i = c.bad; false;) null: null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
+ // [analyzer 8] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
- // [cfe 37] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 83] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C26 {
int? bad;
- // ^
- // [context 38] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 45] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 84] 'bad' refers to a property so it couldn't be promoted.
}
compoundAssignmentRhs(C26 c) {
@@ -491,43 +529,47 @@
if (c.bad == null) return;
n += c.bad;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 45] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 38] A value of type 'int?' can't be assigned to a variable of type 'num' because 'int?' is nullable and 'num' isn't.
+ // [cfe 84] A value of type 'int?' can't be assigned to a variable of type 'num' because 'int?' is nullable and 'num' isn't.
}
class C27 {
int? bad;
- // ^
- // [context 39] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 7] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 85] 'bad' refers to a property so it couldn't be promoted.
}
indexGet(C27 c, List<int> values) {
if (c.bad == null) return;
values[c.bad];
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 7] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 39] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 85] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C28 {
int? bad;
- // ^
- // [context 40] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 23] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 86] 'bad' refers to a property so it couldn't be promoted.
}
indexSet(C28 c, List<int> values) {
if (c.bad == null) return;
values[c.bad] = 0;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 23] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
- // [cfe 40] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
+ // [cfe 86] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C29 {
int? bad;
+ // ^^^
+ // [context 19] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
}
indexSetCompound(C29 c, List<int> values) {
@@ -535,13 +577,15 @@
if (c.bad == null) return;
values[c.bad] += 1;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 19] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
// [cfe] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C30 {
int? bad;
+ // ^^^
+ // [context 37] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
}
indexSetIfNull(C30 c, List<int?> values) {
@@ -549,13 +593,16 @@
if (c.bad == null) return;
values[c.bad] ??= 1;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 37] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
// [cfe] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C31 {
int? bad;
+ // ^^^
+ // [context 31] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 35] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
}
indexSetPreIncDec(C31 c, List<int> values) {
@@ -563,18 +610,21 @@
if (c.bad == null) return;
++values[c.bad];
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 31] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
// [cfe] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
--values[c.bad];
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 35] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
// [cfe] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
class C32 {
int? bad;
+ // ^^^
+ // [context 15] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 34] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
}
indexSetPostIncDec(C32 c, List<int> values) {
@@ -582,12 +632,12 @@
if (c.bad == null) return;
values[c.bad]++;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 34] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
// [cfe] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
values[c.bad]--;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [analyzer 15] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// ^
// [cfe] A value of type 'int?' can't be assigned to a variable of type 'int' because 'int?' is nullable and 'int' isn't.
}
diff --git a/tests/language/why_not_promoted/assignment_error_test.dart b/tests/language/why_not_promoted/assignment_error_test.dart
index 13c21ae..9c1c3a4 100644
--- a/tests/language/why_not_promoted/assignment_error_test.dart
+++ b/tests/language/why_not_promoted/assignment_error_test.dart
@@ -10,61 +10,62 @@
direct_assignment(int? i, int? j) {
if (i == null) return;
i = j;
-//^
-// [context 1] Variable 'i' could not be promoted due to an assignment.
+//^^^^^
+// [context 6] Variable 'i' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+// [context 10] Variable 'i' could not be promoted due to an assignment.
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- //^
- // [cfe 1] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 6] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 10] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
compound_assignment(C? c, int i) {
if (c == null) return;
c += i;
-//^
-// [context 2] Variable 'c' could not be promoted due to an assignment.
+//^^^^^^
+// [context 7] Variable 'c' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+// [context 11] Variable 'c' could not be promoted due to an assignment.
c.cProperty;
// ^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- //^
- // [cfe 2] Property 'cProperty' cannot be accessed on 'C?' because it is potentially null.
+// [analyzer 7] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 11] Property 'cProperty' cannot be accessed on 'C?' because it is potentially null.
}
via_postfix_op(C? c) {
if (c == null) return;
c++;
-//^
-// [context 3] Variable 'c' could not be promoted due to an assignment.
+//^^^
+// [context 4] Variable 'c' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+// [context 12] Variable 'c' could not be promoted due to an assignment.
c.cProperty;
// ^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- //^
- // [cfe 3] Property 'cProperty' cannot be accessed on 'C?' because it is potentially null.
+// [analyzer 4] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 12] Property 'cProperty' cannot be accessed on 'C?' because it is potentially null.
}
via_prefix_op(C? c) {
if (c == null) return;
++c;
+//^^^
+// [context 9] Variable 'c' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
//^
- // [context 4] Variable 'c' could not be promoted due to an assignment.
+ // [context 13] Variable 'c' could not be promoted due to an assignment.
c.cProperty;
// ^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- //^
- // [cfe 4] Property 'cProperty' cannot be accessed on 'C?' because it is potentially null.
+// [analyzer 9] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 13] Property 'cProperty' cannot be accessed on 'C?' because it is potentially null.
}
via_for_each_statement(int? i, List<int?> list) {
if (i == null) return;
for (i in list) {
// ^
- // [context 5] Variable 'i' could not be promoted due to an assignment.
+ // [context 3] Variable 'i' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+ // [context 14] Variable 'i' could not be promoted due to an assignment.
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- //^
- // [cfe 5] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 14] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
}
@@ -72,42 +73,42 @@
if (i == null) return;
[for (i in list) i.isEven];
// ^
- // [context 6] Variable 'i' could not be promoted due to an assignment.
+ // [context 8] Variable 'i' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+ // [context 15] Variable 'i' could not be promoted due to an assignment.
// ^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- // ^
- // [cfe 6] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+ // [analyzer 8] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [cfe 15] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
via_for_each_set_element(int? i, List<int?> list) {
if (i == null) return;
({for (i in list) i.isEven});
// ^
- // [context 7] Variable 'i' could not be promoted due to an assignment.
+ // [context 1] Variable 'i' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+ // [context 16] Variable 'i' could not be promoted due to an assignment.
// ^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- // ^
- // [cfe 7] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+ // [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [cfe 16] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
via_for_each_map_key(int? i, List<int?> list) {
if (i == null) return;
({for (i in list) i.isEven: null});
// ^
- // [context 8] Variable 'i' could not be promoted due to an assignment.
+ // [context 2] Variable 'i' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+ // [context 17] Variable 'i' could not be promoted due to an assignment.
// ^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- // ^
- // [cfe 8] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+ // [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [cfe 17] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
via_for_each_map_value(int? i, List<int?> list) {
if (i == null) return;
({for (i in list) null: i.isEven});
// ^
- // [context 9] Variable 'i' could not be promoted due to an assignment.
+ // [context 5] Variable 'i' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+ // [context 18] Variable 'i' could not be promoted due to an assignment.
// ^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
- // ^
- // [cfe 9] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+ // [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [cfe 18] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
diff --git a/tests/language/why_not_promoted/extension_property_error_test.dart b/tests/language/why_not_promoted/extension_property_error_test.dart
index 7412c73..d7de5cc 100644
--- a/tests/language/why_not_promoted/extension_property_error_test.dart
+++ b/tests/language/why_not_promoted/extension_property_error_test.dart
@@ -7,38 +7,40 @@
if (this.i == null) return;
this.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 1] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 4] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 6] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_property_via_explicit_this_parenthesized() {
if ((this).i == null) return;
(this).i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 2] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 7] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_property_by_implicit_this() {
if (i == null) return;
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 3] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 8] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
}
extension E on C {
int? get i => null;
// ^
- // [context 1] 'i' refers to a property so it couldn't be promoted.
- // [context 2] 'i' refers to a property so it couldn't be promoted.
- // [context 3] 'i' refers to a property so it couldn't be promoted.
- // [context 4] 'i' refers to a property so it couldn't be promoted.
- // [context 5] 'i' refers to a property so it couldn't be promoted.
+ // [context 1] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 2] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 3] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 4] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 5] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 6] 'i' refers to a property so it couldn't be promoted.
+ // [context 7] 'i' refers to a property so it couldn't be promoted.
+ // [context 8] 'i' refers to a property so it couldn't be promoted.
+ // [context 9] 'i' refers to a property so it couldn't be promoted.
+ // [context 10] 'i' refers to a property so it couldn't be promoted.
int? get j => null;
}
@@ -47,9 +49,8 @@
if (i == null) return;
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 4] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 9] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
}
@@ -57,9 +58,8 @@
if (c.i == null) return;
c.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 5] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 10] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_property_via_prefixed_identifier_mismatched_target(C c1, C c2) {
@@ -69,7 +69,6 @@
c2.i.isEven;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
@@ -80,6 +79,5 @@
c.j.isEven;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
diff --git a/tests/language/why_not_promoted/field_error_test.dart b/tests/language/why_not_promoted/field_error_test.dart
index 8193578..d010924 100644
--- a/tests/language/why_not_promoted/field_error_test.dart
+++ b/tests/language/why_not_promoted/field_error_test.dart
@@ -5,39 +5,42 @@
class C {
int? i;
// ^
- // [context 1] 'i' refers to a property so it couldn't be promoted.
- // [context 2] 'i' refers to a property so it couldn't be promoted.
- // [context 3] 'i' refers to a property so it couldn't be promoted.
- // [context 4] 'i' refers to a property so it couldn't be promoted.
- // [context 5] 'i' refers to a property so it couldn't be promoted.
- // [context 6] 'i' refers to a property so it couldn't be promoted.
+ // [context 1] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 2] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 3] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 4] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 5] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 6] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 7] 'i' refers to a property so it couldn't be promoted.
+ // [context 8] 'i' refers to a property so it couldn't be promoted.
+ // [context 9] 'i' refers to a property so it couldn't be promoted.
+ // [context 10] 'i' refers to a property so it couldn't be promoted.
+ // [context 11] 'i' refers to a property so it couldn't be promoted.
+ // [context 12] 'i' refers to a property so it couldn't be promoted.
int? j;
get_field_via_explicit_this() {
if (this.i == null) return;
this.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 1] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 7] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_field_via_explicit_this_parenthesized() {
if ((this).i == null) return;
(this).i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 2] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 8] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_field_by_implicit_this() {
if (i == null) return;
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 3] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 9] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
}
@@ -46,18 +49,16 @@
if (super.i == null) return;
super.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 4] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 4] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 10] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_field_by_implicit_super() {
if (i == null) return;
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 5] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 11] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
}
@@ -65,9 +66,8 @@
if (c.i == null) return;
c.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 6] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 6] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 12] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_field_via_prefixed_identifier_mismatched_target(C c1, C c2) {
@@ -77,7 +77,6 @@
c2.i.isEven;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
@@ -88,6 +87,5 @@
c.j.isEven;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
diff --git a/tests/language/why_not_promoted/for_in_loop_type_not_iterable_nullability_error_test.dart b/tests/language/why_not_promoted/for_in_loop_type_not_iterable_nullability_error_test.dart
index 225e86b..ecf7b84 100644
--- a/tests/language/why_not_promoted/for_in_loop_type_not_iterable_nullability_error_test.dart
+++ b/tests/language/why_not_promoted/for_in_loop_type_not_iterable_nullability_error_test.dart
@@ -9,85 +9,93 @@
class C1 {
List<int>? bad;
- // ^
- // [context 1] 'bad' refers to a property so it couldn't be promoted.
- // [context 2] 'bad' refers to a property so it couldn't be promoted.
- // [context 3] 'bad' refers to a property so it couldn't be promoted.
- // [context 4] 'bad' refers to a property so it couldn't be promoted.
- // [context 5] 'bad' refers to a property so it couldn't be promoted.
- // [context 6] 'bad' refers to a property so it couldn't be promoted.
- // [context 7] 'bad' refers to a property so it couldn't be promoted.
- // [context 8] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 1] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 2] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 3] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 4] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 5] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 6] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 7] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 8] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 9] 'bad' refers to a property so it couldn't be promoted.
+ // [context 10] 'bad' refers to a property so it couldn't be promoted.
+ // [context 11] 'bad' refers to a property so it couldn't be promoted.
+ // [context 12] 'bad' refers to a property so it couldn't be promoted.
+ // [context 13] 'bad' refers to a property so it couldn't be promoted.
+ // [context 14] 'bad' refers to a property so it couldn't be promoted.
+ // [context 15] 'bad' refers to a property so it couldn't be promoted.
+ // [context 16] 'bad' refers to a property so it couldn't be promoted.
}
forStatement(C1 c) {
if (c.bad == null) return;
for (var x in c.bad) {}
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 6] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 1] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 9] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
forElementInList(C1 c) {
if (c.bad == null) return;
[for (var x in c.bad) null];
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 7] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 2] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 10] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
forElementInSet(C1 c) {
if (c.bad == null) return;
<dynamic>{for (var x in c.bad) null};
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 3] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 11] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
forElementInMap(C1 c) {
if (c.bad == null) return;
<dynamic, dynamic>{for (var x in c.bad) null: null};
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 4] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 12] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
forElementInAmbiguousSet_resolvableDuringParsing(C1 c) {
if (c.bad == null) return;
({for (var x in c.bad) null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 5] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 13] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
forElementInAmbiguousMap_resolvableDuringParsing(C1 c) {
if (c.bad == null) return;
({for (var x in c.bad) null: null});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 6] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 14] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
forElementInAmbiguousSet_notResolvableDuringParsing(C1 c, List list) {
if (c.bad == null) return;
({for (var x in c.bad) ...list});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 4] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 7] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 15] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
forElementInAmbiguousMap_notResolvableDuringParsing(C1 c, Map map) {
if (c.bad == null) return;
({for (var x in c.bad) ...map});
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 8] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 8] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 16] The type 'List<int>?' used in the 'for' loop must implement 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
diff --git a/tests/language/why_not_promoted/invalid_assignment_error_nullability_error_test.dart b/tests/language/why_not_promoted/invalid_assignment_error_nullability_error_test.dart
index 78da0e8..67f6c40 100644
--- a/tests/language/why_not_promoted/invalid_assignment_error_nullability_error_test.dart
+++ b/tests/language/why_not_promoted/invalid_assignment_error_nullability_error_test.dart
@@ -9,16 +9,17 @@
class C1 {
List<int>? bad;
- // ^
- // [context 1] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 1] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 2] 'bad' refers to a property so it couldn't be promoted.
}
test(C1 c) sync* {
if (c.bad == null) return;
yield* c.bad;
// ^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// [analyzer] COMPILE_TIME_ERROR.YIELD_OF_INVALID_TYPE
// ^
- // [cfe 1] A value of type 'List<int>?' can't be assigned to a variable of type 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
+ // [cfe 2] A value of type 'List<int>?' can't be assigned to a variable of type 'Iterable<dynamic>' because 'List<int>?' is nullable and 'Iterable<dynamic>' isn't.
}
diff --git a/tests/language/why_not_promoted/nullable_expression_call_error_test.dart b/tests/language/why_not_promoted/nullable_expression_call_error_test.dart
index c12b0e5..e1f286a 100644
--- a/tests/language/why_not_promoted/nullable_expression_call_error_test.dart
+++ b/tests/language/why_not_promoted/nullable_expression_call_error_test.dart
@@ -8,8 +8,9 @@
class C1 {
C2? bad;
- // ^
- // [context 1] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 3] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 7] 'bad' refers to a property so it couldn't be promoted.
}
class C2 {
@@ -20,16 +21,17 @@
if (c.bad == null) return;
c.bad();
//^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
-// [cfe 1] Can't use an expression of type 'C2?' as a function because it's potentially null.
+// [cfe 7] Can't use an expression of type 'C2?' as a function because it's potentially null.
}
class C3 {
C4? ok;
C5? bad;
- // ^
- // [context 2] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 1] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 8] 'bad' refers to a property so it couldn't be promoted.
}
class C4 {}
@@ -50,15 +52,16 @@
if (c.bad == null) return;
c.bad();
//^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
-// [cfe 2] Can't use an expression of type 'C5?' as a function because it's potentially null.
+// [cfe 8] Can't use an expression of type 'C5?' as a function because it's potentially null.
}
class C6 {
C7? bad;
- // ^
- // [context 3] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 6] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 9] 'bad' refers to a property so it couldn't be promoted.
}
class C7 {
@@ -70,16 +73,17 @@
c.bad();
//^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [analyzer 6] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
-// [cfe 3] Can't use an expression of type 'C7?' as a function because it's potentially null.
+// [cfe 9] Can't use an expression of type 'C7?' as a function because it's potentially null.
}
class C8 {
C9? ok;
C10? bad;
- // ^
- // [context 4] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 4] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 10] 'bad' refers to a property so it couldn't be promoted.
}
class C9 {}
@@ -104,30 +108,32 @@
if (c.bad == null) return;
c.bad();
//^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [analyzer 4] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
-// [cfe 4] Can't use an expression of type 'C10?' as a function because it's potentially null.
+// [cfe 10] Can't use an expression of type 'C10?' as a function because it's potentially null.
}
class C11 {
void Function()? bad;
- // ^
- // [context 5] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 5] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 11] 'bad' refers to a property so it couldn't be promoted.
}
function_invocation(C11 c) {
if (c.bad == null) return;
c.bad();
//^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
-// [cfe 5] Can't use an expression of type 'void Function()?' as a function because it's potentially null.
+// [cfe 11] Can't use an expression of type 'void Function()?' as a function because it's potentially null.
}
class C12 {
C13? bad;
- // ^
- // [context 6] 'bad' refers to a property so it couldn't be promoted.
+ // ^^^
+ // [context 2] 'bad' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 12] 'bad' refers to a property so it couldn't be promoted.
}
class C13 {
@@ -141,7 +147,6 @@
// https://github.com/dart-lang/sdk/issues/45552
c.bad.foo();
// ^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 6] Can't use an expression of type 'C13?' as a function because it's potentially null.
+// [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 12] Can't use an expression of type 'C13?' as a function because it's potentially null.
}
diff --git a/tests/language/why_not_promoted/nullable_method_call_error_test.dart b/tests/language/why_not_promoted/nullable_method_call_error_test.dart
index be1bba1..56d5e93 100644
--- a/tests/language/why_not_promoted/nullable_method_call_error_test.dart
+++ b/tests/language/why_not_promoted/nullable_method_call_error_test.dart
@@ -9,13 +9,18 @@
class C {
int? i;
// ^
- // [context 3] 'i' refers to a property so it couldn't be promoted.
- // [context 4] 'i' refers to a property so it couldn't be promoted.
- // [context 5] 'i' refers to a property so it couldn't be promoted.
- // [context 6] 'i' refers to a property so it couldn't be promoted.
+ // [context 2] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 3] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 4] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 5] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 10] 'i' refers to a property so it couldn't be promoted.
+ // [context 11] 'i' refers to a property so it couldn't be promoted.
+ // [context 12] 'i' refers to a property so it couldn't be promoted.
+ // [context 13] 'i' refers to a property so it couldn't be promoted.
void Function()? f;
// ^
- // [context 7] 'f' refers to a property so it couldn't be promoted.
+ // [context 7] 'f' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 14] 'f' refers to a property so it couldn't be promoted.
}
extension on int {
@@ -31,35 +36,34 @@
property_get_of_variable(int? i, int? j) {
if (i == null) return;
i = j;
-//^
-// [context 1] Variable 'i' could not be promoted due to an assignment.
+//^^^^^
+// [context 6] Variable 'i' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+// [context 8] Variable 'i' could not be promoted due to an assignment.
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 1] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 6] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 8] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
extension_property_get_of_variable(int? i, int? j) {
if (i == null) return;
i = j;
-//^
-// [context 2] Variable 'i' could not be promoted due to an assignment.
+//^^^^^
+// [context 1] Variable 'i' could not be promoted due to an assignment. See http://dart.dev/go/non-promo-write
+// [context 9] Variable 'i' could not be promoted due to an assignment.
i.propertyOnNullableInt;
i.propertyOnNonNullInt;
// ^^^^^^^^^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 2] Property 'propertyOnNonNullInt' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 9] Property 'propertyOnNonNullInt' cannot be accessed on 'int?' because it is potentially null.
}
property_get_of_expression(C c) {
if (c.i == null) return;
c.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 3] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 10] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
extension_property_get_of_expression(C c) {
@@ -67,18 +71,16 @@
c.i.propertyOnNullableInt;
c.i.propertyOnNonNullInt;
// ^^^^^^^^^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 4] Property 'propertyOnNonNullInt' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 11] Property 'propertyOnNonNullInt' cannot be accessed on 'int?' because it is potentially null.
}
method_invocation(C c) {
if (c.i == null) return;
c.i.abs();
// ^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 5] Method 'abs' cannot be called on 'int?' because it is potentially null.
+// [analyzer 4] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 12] Method 'abs' cannot be called on 'int?' because it is potentially null.
}
extension_method_invocation(C c) {
@@ -86,16 +88,14 @@
c.i.methodOnNullableInt();
c.i.methodOnNonNullInt();
// ^^^^^^^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 6] Method 'methodOnNonNullInt' cannot be called on 'int?' because it is potentially null.
+// [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 13] Method 'methodOnNonNullInt' cannot be called on 'int?' because it is potentially null.
}
call_invocation(C c) {
if (c.f == null) return;
c.f.call();
// ^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 7] Method 'call' cannot be called on 'void Function()?' because it is potentially null.
+// [analyzer 7] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 14] Method 'call' cannot be called on 'void Function()?' because it is potentially null.
}
diff --git a/tests/language/why_not_promoted/nullable_spread_error_test.dart b/tests/language/why_not_promoted/nullable_spread_error_test.dart
index 3d9e669..03d98ed 100644
--- a/tests/language/why_not_promoted/nullable_spread_error_test.dart
+++ b/tests/language/why_not_promoted/nullable_spread_error_test.dart
@@ -8,47 +8,63 @@
class C {
List<int>? listQuestion;
- // ^
- // [context 1] 'listQuestion' refers to a property so it couldn't be promoted.
- // [context 5] 'listQuestion' refers to a property so it couldn't be promoted.
- // [context 11] 'listQuestion' refers to a property so it couldn't be promoted.
+ // ^^^^^^^^^^^^
+ // [context 7] 'listQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 9] 'listQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 15] 'listQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 17] 'listQuestion' refers to a property so it couldn't be promoted.
+ // [context 21] 'listQuestion' refers to a property so it couldn't be promoted.
+ // [context 27] 'listQuestion' refers to a property so it couldn't be promoted.
Object? objectQuestion;
- // ^
- // [context 4] 'objectQuestion' refers to a property so it couldn't be promoted.
- // [context 8] 'objectQuestion' refers to a property so it couldn't be promoted.
- // [context 9] 'objectQuestion' refers to a property so it couldn't be promoted.
- // [context 10] 'objectQuestion' refers to a property so it couldn't be promoted.
- // [context 14] 'objectQuestion' refers to a property so it couldn't be promoted.
- // [context 15] 'objectQuestion' refers to a property so it couldn't be promoted.
+ // ^^^^^^^^^^^^^^
+ // [context 1] 'objectQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 6] 'objectQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 10] 'objectQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 11] 'objectQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 12] 'objectQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 16] 'objectQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 20] 'objectQuestion' refers to a property so it couldn't be promoted.
+ // [context 24] 'objectQuestion' refers to a property so it couldn't be promoted.
+ // [context 25] 'objectQuestion' refers to a property so it couldn't be promoted.
+ // [context 26] 'objectQuestion' refers to a property so it couldn't be promoted.
+ // [context 30] 'objectQuestion' refers to a property so it couldn't be promoted.
+ // [context 31] 'objectQuestion' refers to a property so it couldn't be promoted.
Set<int>? setQuestion;
- // ^
- // [context 2] 'setQuestion' refers to a property so it couldn't be promoted.
- // [context 6] 'setQuestion' refers to a property so it couldn't be promoted.
- // [context 12] 'setQuestion' refers to a property so it couldn't be promoted.
- // [context 16] 'setQuestion' refers to a property so it couldn't be promoted.
+ // ^^^^^^^^^^^
+ // [context 4] 'setQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 5] 'setQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 8] 'setQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 14] 'setQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 18] 'setQuestion' refers to a property so it couldn't be promoted.
+ // [context 22] 'setQuestion' refers to a property so it couldn't be promoted.
+ // [context 28] 'setQuestion' refers to a property so it couldn't be promoted.
+ // [context 32] 'setQuestion' refers to a property so it couldn't be promoted.
Map<int, int>? mapQuestion;
- // ^
- // [context 3] 'mapQuestion' refers to a property so it couldn't be promoted.
- // [context 7] 'mapQuestion' refers to a property so it couldn't be promoted.
- // [context 13] 'mapQuestion' refers to a property so it couldn't be promoted.
+ // ^^^^^^^^^^^
+ // [context 2] 'mapQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 3] 'mapQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 13] 'mapQuestion' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 19] 'mapQuestion' refers to a property so it couldn't be promoted.
+ // [context 23] 'mapQuestion' refers to a property so it couldn't be promoted.
+ // [context 29] 'mapQuestion' refers to a property so it couldn't be promoted.
}
list_from_list_question(C c) {
if (c.listQuestion == null) return;
return [...c.listQuestion];
// ^^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 7] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 1] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 17] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}
list_from_set_question(C c) {
if (c.setQuestion == null) return;
return [...c.setQuestion];
// ^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 4] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 2] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 18] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}
list_from_map_question(C c) {
@@ -56,9 +72,9 @@
return [...c.mapQuestion];
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ITERABLE_SPREAD
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 3] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 19] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
// [cfe] Unexpected type 'Map<int, int>?' of a spread. Expected 'dynamic' or an Iterable.
}
@@ -67,9 +83,9 @@
return [...c.objectQuestion];
// ^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ITERABLE_SPREAD
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 16] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 4] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 20] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
// [cfe] Unexpected type 'Object?' of a spread. Expected 'dynamic' or an Iterable.
}
@@ -77,27 +93,27 @@
if (c.listQuestion == null) return;
return {...c.listQuestion};
// ^^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 9] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 5] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 21] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}
set_from_set_question(C c) {
if (c.setQuestion == null) return;
return {...c.setQuestion};
// ^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 6] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 22] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}
set_from_map_question(C c) {
if (c.mapQuestion == null) return;
return {...c.mapQuestion};
// ^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 7] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 23] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}
set_from_object_question_type_disambiguate_by_entry(C c) {
@@ -106,9 +122,9 @@
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER
// ^^^^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 6] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 8] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 24] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
// [cfe] Unexpected type 'Object?' of a spread. Expected 'dynamic' or an Iterable.
}
@@ -118,9 +134,9 @@
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER
// ^^^^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 12] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 9] Unexpected type 'Object?' of a map spread entry. Expected 'dynamic' or a Map.
+ // [cfe 25] Unexpected type 'Object?' of a map spread entry. Expected 'dynamic' or a Map.
}
set_from_object_question_type_disambiguate_by_literal_args(C c) {
@@ -128,9 +144,9 @@
return <int>{...c.objectQuestion};
// ^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ITERABLE_SPREAD
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 10] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 26] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
// [cfe] Unexpected type 'Object?' of a spread. Expected 'dynamic' or an Iterable.
}
@@ -138,27 +154,27 @@
if (c.listQuestion == null) return;
return {...c.listQuestion};
// ^^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 15] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 11] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 27] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}
map_from_set_question(C c) {
if (c.setQuestion == null) return;
return {...c.setQuestion};
// ^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 14] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 12] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 28] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}
map_from_map_question(C c) {
if (c.mapQuestion == null) return;
return {...c.mapQuestion};
// ^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 13] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 13] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 29] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}
map_from_object_question_type_disambiguate_by_key_value_pair(C c) {
@@ -167,9 +183,9 @@
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER
// ^^^^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 10] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 14] Unexpected type 'Object?' of a map spread entry. Expected 'dynamic' or a Map.
+ // [cfe 30] Unexpected type 'Object?' of a map spread entry. Expected 'dynamic' or a Map.
}
map_from_object_question_type_disambiguate_by_previous_spread(C c) {
@@ -178,9 +194,9 @@
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER
// ^^^^^^^^^^^^^^^^
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 11] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 15] Unexpected type 'Object?' of a map spread entry. Expected 'dynamic' or a Map.
+ // [cfe 31] Unexpected type 'Object?' of a map spread entry. Expected 'dynamic' or a Map.
}
map_from_set_question_type_disambiguate_by_literal_args(C c) {
@@ -192,8 +208,8 @@
return <int, int>{...c.setQuestion};
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_MAP_SPREAD
- // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+ // [analyzer 8] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
- // [cfe 16] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
+ // [cfe 32] An expression whose value can be 'null' must be null-checked before it can be dereferenced.
// [cfe] Unexpected type 'Set<int>?' of a map spread entry. Expected 'dynamic' or a Map.
}
diff --git a/tests/language/why_not_promoted/property_error_test.dart b/tests/language/why_not_promoted/property_error_test.dart
index 330a21e..02b1615 100644
--- a/tests/language/why_not_promoted/property_error_test.dart
+++ b/tests/language/why_not_promoted/property_error_test.dart
@@ -5,39 +5,42 @@
class C {
int? get i => null;
// ^
- // [context 1] 'i' refers to a property so it couldn't be promoted.
- // [context 2] 'i' refers to a property so it couldn't be promoted.
- // [context 3] 'i' refers to a property so it couldn't be promoted.
- // [context 4] 'i' refers to a property so it couldn't be promoted.
- // [context 5] 'i' refers to a property so it couldn't be promoted.
- // [context 6] 'i' refers to a property so it couldn't be promoted.
+ // [context 1] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 2] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 3] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 4] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 5] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 6] 'i' refers to a property so it couldn't be promoted. See http://dart.dev/go/non-promo-property
+ // [context 7] 'i' refers to a property so it couldn't be promoted.
+ // [context 8] 'i' refers to a property so it couldn't be promoted.
+ // [context 9] 'i' refers to a property so it couldn't be promoted.
+ // [context 10] 'i' refers to a property so it couldn't be promoted.
+ // [context 11] 'i' refers to a property so it couldn't be promoted.
+ // [context 12] 'i' refers to a property so it couldn't be promoted.
int? get j => null;
get_property_via_explicit_this() {
if (this.i == null) return;
this.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 1] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 7] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_property_via_explicit_this_parenthesized() {
if ((this).i == null) return;
(this).i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 2] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 3] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 8] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_property_by_implicit_this() {
if (i == null) return;
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 3] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 4] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 9] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
}
@@ -46,18 +49,16 @@
if (super.i == null) return;
super.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 4] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 6] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 10] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_property_by_implicit_super() {
if (i == null) return;
i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 5] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 5] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 11] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
}
@@ -65,9 +66,8 @@
if (c.i == null) return;
c.i.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
-// [cfe 6] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [cfe 12] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
get_property_via_prefixed_identifier_mismatched_target(C c1, C c2) {
@@ -77,7 +77,6 @@
c2.i.isEven;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
@@ -88,6 +87,5 @@
c.j.isEven;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
diff --git a/tests/language/why_not_promoted/this_error_test.dart b/tests/language/why_not_promoted/this_error_test.dart
index 9c2a1d4..2d836ee 100644
--- a/tests/language/why_not_promoted/this_error_test.dart
+++ b/tests/language/why_not_promoted/this_error_test.dart
@@ -15,8 +15,8 @@
if (this == null) return;
this.isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// ^
+// [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [context 2] 'this' can't be promoted. See http://dart.dev/go/non-promo-this
// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
@@ -25,7 +25,8 @@
if (this == null) return;
isEven;
// ^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [context 1] 'this' can't be promoted. See http://dart.dev/go/non-promo-this
// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
}
}
diff --git a/tests/modular/private_class_exposed_by_typedef/main.dart b/tests/modular/private_class_exposed_by_typedef/main.dart
new file mode 100644
index 0000000..70c26d1
--- /dev/null
+++ b/tests/modular/private_class_exposed_by_typedef/main.dart
@@ -0,0 +1,61 @@
+// Copyright (c) 2021, 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.
+
+import "package:expect/expect.dart";
+
+import "private_name_library.dart";
+
+// These tests are adapted from the set located in
+// language/nonfunction_type_aliases/private_names/ to highlight a specific
+// DDC issue with public fields in private classes.
+
+void main() {
+ test1();
+ test2();
+}
+
+/// Extend a private class via a public typedef without overriding any methods.
+class Derived extends PublicClass {
+ Derived() : super();
+}
+
+/// Extend a private class via a public typedef overriding methods and
+/// properties. The final field `x` is overriden with a getter which returns
+/// different values every time it is called.
+class AlsoDerived extends AlsoPublicClass {
+ int backingStore = publicNameSentinel;
+ int get x => ++backingStore;
+ int get y => super.x;
+ AlsoDerived() : super.named(privateNameSentinel);
+}
+
+/// Test that inherited properties work correctly
+void test1() {
+ var p = Derived();
+ // Reading the virtual field should give the private value
+ Expect.equals(privateNameSentinel, p.x);
+ // Reading the virtual field from the private library should give the private
+ // value
+ Expect.equals(privateNameSentinel, readInstanceField(p));
+}
+
+/// Test that overridden properties work correctly.
+void test2() {
+ var p = AlsoDerived();
+ // Reading the original virtual field should give the private value.
+ Expect.equals(privateNameSentinel, p.y);
+ // Reading the overriding getter from the private library should give the
+ // public value and increment it each time it is called.
+ Expect.equals(publicNameSentinel, p.backingStore);
+ Expect.equals(publicNameSentinel + 1, readInstanceField2(p));
+ Expect.equals(publicNameSentinel + 1, p.backingStore);
+ // Reading the overriding getter from the original library should give the
+ // public value and increment it each time it is called.
+ Expect.equals(publicNameSentinel + 2, p.x);
+ Expect.equals(publicNameSentinel + 2, p.backingStore);
+ Expect.equals(privateNameSentinel, p.y);
+ Expect.equals(publicNameSentinel + 2, p.backingStore);
+ Expect.equals(publicNameSentinel + 3, readInstanceField2(p));
+ Expect.equals(publicNameSentinel + 4, p.x);
+}
diff --git a/tests/modular/private_class_exposed_by_typedef/modules.yaml b/tests/modular/private_class_exposed_by_typedef/modules.yaml
new file mode 100644
index 0000000..530016e
--- /dev/null
+++ b/tests/modular/private_class_exposed_by_typedef/modules.yaml
@@ -0,0 +1,8 @@
+# Copyright (c) 2021, 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.
+#
+dependencies:
+ main: [expect, private_name_library]
+flags:
+ - nonfunction-type-aliases
diff --git a/tests/modular/private_class_exposed_by_typedef/private_name_library.dart b/tests/modular/private_class_exposed_by_typedef/private_name_library.dart
new file mode 100644
index 0000000..74559cc
--- /dev/null
+++ b/tests/modular/private_class_exposed_by_typedef/private_name_library.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2021, 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.
+// Shared code for tests that private names exported publicly via a typedef work
+// as expected.
+library private;
+
+/// Sentinel values for checking that the correct methods are called.
+const int privateNameSentinel = -1;
+const int publicNameSentinel = privateNameSentinel + 1;
+
+/// A private class that will be exported via a public typedef.
+class _PrivateClass {
+ int x;
+ _PrivateClass(): x = privateNameSentinel;
+ _PrivateClass.named(this.x);
+}
+
+class _PrivateClass2 {
+ int x;
+ _PrivateClass2(): x = privateNameSentinel;
+ _PrivateClass2.named(this.x);
+}
+
+/// Export the private class publicly.
+typedef PublicClass = _PrivateClass;
+
+/// Export the private class publicly via an indirection through another private
+/// typedef.
+typedef _PrivateTypeDef = _PrivateClass2;
+typedef AlsoPublicClass = _PrivateTypeDef;
+
+/// Helper methods to do virtual calls on instances of _PrivateClass in this
+/// library context.
+int readInstanceField(_PrivateClass other) => other.x;
+
+/// Helper methods to do virtual calls on instances of _PrivateClass in this
+/// library context.
+int readInstanceField2(_PrivateClass2 other) => other.x;
diff --git a/tools/VERSION b/tools/VERSION
index 043770a..8021494 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 13
PATCH 0
-PRERELEASE 204
+PRERELEASE 205
PRERELEASE_PATCH 0
\ No newline at end of file