mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
c9e2b012b1
Prior to this CL, the CFE used a nullable type schema for null-aware spread operators in list literals, but a non-nullable type schema for null-aware spread operators in set and map literals. This was clearly an oversight; a nullable type schema should be used for for null-aware spread operators in all kinds of collection literals. This change brings the CFE into alignment with the analyzer. Fixes https://github.com/dart-lang/sdk/issues/54828. Change-Id: I0d5aa128656c22211228f0dd35ccee40925b4ef0 Bug: https://github.com/dart-lang/sdk/issues/54828 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349921 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
38 lines
1.1 KiB
Dart
38 lines
1.1 KiB
Dart
// Copyright (c) 2024, 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.
|
|
|
|
// Test that the context type schema for a null-aware spread is correct (it
|
|
// should be nullable compared to context type schema for a non-null-aware
|
|
// spread).
|
|
|
|
import '../static_type_helper.dart';
|
|
|
|
main() {
|
|
{
|
|
List<int> notNullAware = [
|
|
...(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>>>())
|
|
];
|
|
List<int> nullAware = [
|
|
...?(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>?>>())
|
|
];
|
|
}
|
|
{
|
|
Set<int> notNullAware = {
|
|
...(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>>>())
|
|
};
|
|
Set<int> nullAware = {
|
|
...?(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>?>>())
|
|
};
|
|
}
|
|
{
|
|
Map<int, int> notNullAware = {
|
|
...(contextType(<int, int>{})..expectStaticType<Exactly<Map<int, int>>>())
|
|
};
|
|
Map<int, int> nullAware = {
|
|
...?(contextType(<int, int>{})
|
|
..expectStaticType<Exactly<Map<int, int>?>>())
|
|
};
|
|
}
|
|
}
|