38d7c7661d
In error reporting on assignability where the expression has type `Null` we use a special messages that doesn't state that "'Null' is nullable". Cases where `Null` is part of the type or where the expression of type `Null` is derived from a collection are not special cased. Closes #43998 Closes #44093 Change-Id: Ic0c79e6362f2365eb3fe8222ccd2ef8fac4f188d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170433 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
16 lines
626 B
Dart
16 lines
626 B
Dart
// Copyright (c) 2020, 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.
|
|
|
|
// This version should continue to opt in to null safety in purpetuity (or at
|
|
// least until Dart 3), when the experiment is enabled.
|
|
// @dart = 2.12
|
|
|
|
void main() {
|
|
// This should be an error since we are opted in.
|
|
int x = null;
|
|
// ^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
|
|
// [cfe] The value 'null' can't be assigned to a variable of type 'int' because 'int' is not nullable.
|
|
}
|