[cfe] Adjust nullability of UP when r.h.s. is an intersection

Closes https://github.com/dart-lang/sdk/issues/48373

Change-Id: I9ec2211c6deccbc7c26e831863f9a9b05833380f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
This commit is contained in:
Chloe Stefantsova 2022-03-14 15:44:38 +00:00 committed by Commit Bot
parent be207fbc54
commit ad3d2eb5c4
8 changed files with 50 additions and 2 deletions

View file

@ -0,0 +1,10 @@
// Copyright (c) 2022, 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.
void fn<T, S>(T? t, S? s) {
var x = [t!, s!];
List<Object> y = x; // Ok.
}
main() {}

View file

@ -0,0 +1,2 @@
void fn<T, S>(T? t, S? s) {}
main() {}

View file

@ -0,0 +1,2 @@
main() {}
void fn<T, S>(T? t, S? s) {}

View file

@ -0,0 +1,9 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method fn<T extends core::Object? = dynamic, S extends core::Object? = dynamic>(self::fn::T? t, self::fn::S? s) → void {
core::List<core::Object> x = <core::Object>[t!, s!];
core::List<core::Object> y = x;
}
static method main() → dynamic {}

View file

@ -0,0 +1,9 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method fn<T extends core::Object? = dynamic, S extends core::Object? = dynamic>(self::fn::T? t, self::fn::S? s) → void {
core::List<core::Object> x = <core::Object>[t!, s!];
core::List<core::Object> y = x;
}
static method main() → dynamic {}

View file

@ -0,0 +1,8 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method fn<T extends core::Object? = dynamic, S extends core::Object? = dynamic>(self::fn::T? t, self::fn::S? s) → void
;
static method main() → dynamic
;

View file

@ -0,0 +1,9 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method fn<T extends core::Object? = dynamic, S extends core::Object? = dynamic>(self::fn::T? t, self::fn::S? s) → void {
core::List<core::Object> x = core::_GrowableList::_literal2<core::Object>(t!, s!);
core::List<core::Object> y = x;
}
static method main() → dynamic {}

View file

@ -1274,8 +1274,7 @@ mixin StandardBounds {
type2,
clientLibrary)
.withDeclaredNullability(uniteNullabilities(
type1.promotedBound!.declaredNullability,
type2.declaredNullability));
type1.promotedBound!.declaredNullability, type2.nullability));
}
}