Skip to content

Commit

Permalink
[cfe] Adjust nullability of FutureOrType after substitution
Browse files Browse the repository at this point in the history
Bug: #48631
Change-Id: I329a70386d59425cf3f157dc4b6316649f8aa389
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240049
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Chloe Stefantsova <[email protected]>
  • Loading branch information
chloestefantsova authored and Commit Bot committed Apr 5, 2022
1 parent 3436650 commit 7d8d3bb
Show file tree
Hide file tree
Showing 19 changed files with 377 additions and 1 deletion.
13 changes: 13 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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.

import 'dart:async';

FutureOr<T?> foo<T>(T t) {}

bar<S>(bool t, S s) {
var x = [foo(s), s];
}

main() {}
11 changes: 11 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_1.dart.strong.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;

import "dart:async";

static method foo<T extends core::Object? = dynamic>(self::foo::T% t) → FutureOr<self::foo::T?> {}
static method bar<S extends core::Object? = dynamic>(core::bool t, self::bar::S% s) → dynamic {
core::List<FutureOr<self::bar::S?>?> x = <FutureOr<self::bar::S?>?>[self::foo<self::bar::S%>(s), s];
}
static method main() → dynamic {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;

import "dart:async";

static method foo<T extends core::Object? = dynamic>(self::foo::T% t) → FutureOr<self::foo::T?> {}
static method bar<S extends core::Object? = dynamic>(core::bool t, self::bar::S% s) → dynamic {
core::List<FutureOr<self::bar::S?>?> x = core::_GrowableList::_literal2<FutureOr<self::bar::S?>?>(self::foo<self::bar::S%>(s), s);
}
static method main() → dynamic {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'dart:async';

FutureOr<T?> foo<T>(T t) {}
bar<S>(bool t, S s) {}
main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'dart:async';

FutureOr<T?> foo<T>(T t) {}
bar<S>(bool t, S s) {}
main() {}
11 changes: 11 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_1.dart.weak.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;

import "dart:async";

static method foo<T extends core::Object? = dynamic>(self::foo::T% t) → FutureOr<self::foo::T?> {}
static method bar<S extends core::Object? = dynamic>(core::bool t, self::bar::S% s) → dynamic {
core::List<FutureOr<self::bar::S?>?> x = <FutureOr<self::bar::S?>?>[self::foo<self::bar::S%>(s), s];
}
static method main() → dynamic {}
11 changes: 11 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_1.dart.weak.modular.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;

import "dart:async";

static method foo<T extends core::Object? = dynamic>(self::foo::T% t) → FutureOr<self::foo::T?> {}
static method bar<S extends core::Object? = dynamic>(core::bool t, self::bar::S% s) → dynamic {
core::List<FutureOr<self::bar::S?>?> x = <FutureOr<self::bar::S?>?>[self::foo<self::bar::S%>(s), s];
}
static method main() → dynamic {}
12 changes: 12 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_1.dart.weak.outline.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;

import "dart:async";

static method foo<T extends core::Object? = dynamic>(self::foo::T% t) → FutureOr<self::foo::T?>
;
static method bar<S extends core::Object? = dynamic>(core::bool t, self::bar::S% s) → dynamic
;
static method main() → dynamic
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;

import "dart:async";

static method foo<T extends core::Object? = dynamic>(self::foo::T% t) → FutureOr<self::foo::T?> {}
static method bar<S extends core::Object? = dynamic>(core::bool t, self::bar::S% s) → dynamic {
core::List<FutureOr<self::bar::S?>?> x = core::_GrowableList::_literal2<FutureOr<self::bar::S?>?>(self::foo<self::bar::S%>(s), s);
}
static method main() → dynamic {}
29 changes: 29 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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.

import 'dart:async';

abstract class A {
T foo<T>(B<T> b);
}

class B<X> {
B(X x);
}

class C<Y> {
final Bar<FutureOr<Y>, D<Y>> bar;

C(this.bar);
}

abstract class D<W> implements A {}

typedef Bar<V, U extends A> = V Function(U);

final baz = C<int>((a) {
return a.foo(B(Future.value(0)));
});

main() {}
34 changes: 34 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_2.dart.strong.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:async" as asy;

import "dart:async";

typedef Bar<V extends core::Object? = dynamic, contravariant U extends self::A> = (U) → V%;
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
abstract method foo<T extends core::Object? = dynamic>(self::B<self::A::foo::T%> b) → self::A::foo::T%;
}
class B<X extends core::Object? = dynamic> extends core::Object {
constructor •(self::B::X% x) → self::B<self::B::X%>
: super core::Object::•()
;
}
class C<Y extends core::Object? = dynamic> extends core::Object {
final field (self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar;
constructor •((self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar) → self::C<self::C::Y%>
: self::C::bar = bar, super core::Object::•()
;
}
abstract class D<W extends core::Object? = dynamic> extends core::Object implements self::A {
synthetic constructor •() → self::D<self::D::W%>
: super core::Object::•()
;
}
static final field self::C<core::int> baz = new self::C::•<core::int>((self::D<core::int> a) → FutureOr<core::int> {
return a.{self::A::foo}<FutureOr<core::int>>(new self::B::•<FutureOr<core::int>>(asy::Future::value<core::int>(0))){(self::B<FutureOr<core::int>>) → FutureOr<core::int>};
});
static method main() → dynamic {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:async" as asy;

import "dart:async";

typedef Bar<V extends core::Object? = dynamic, contravariant U extends self::A> = (U) → V%;
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
abstract method foo<T extends core::Object? = dynamic>(self::B<self::A::foo::T%> b) → self::A::foo::T%;
}
class B<X extends core::Object? = dynamic> extends core::Object {
constructor •(self::B::X% x) → self::B<self::B::X%>
: super core::Object::•()
;
}
class C<Y extends core::Object? = dynamic> extends core::Object {
final field (self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar;
constructor •((self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar) → self::C<self::C::Y%>
: self::C::bar = bar, super core::Object::•()
;
}
abstract class D<W extends core::Object? = dynamic> extends core::Object implements self::A {
synthetic constructor •() → self::D<self::D::W%>
: super core::Object::•()
;
}
static final field self::C<core::int> baz = new self::C::•<core::int>((self::D<core::int> a) → FutureOr<core::int> {
return a.{self::A::foo}<FutureOr<core::int>>(new self::B::•<FutureOr<core::int>>(asy::Future::value<core::int>(0))){(self::B<FutureOr<core::int>>) → FutureOr<core::int>};
});
static method main() → dynamic {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'dart:async';

abstract class A {
T foo<T>(B<T> b);
}

class B<X> {
B(X x);
}

class C<Y> {
final Bar<FutureOr<Y>, D<Y>> bar;
C(this.bar);
}

abstract class D<W> implements A {}

typedef Bar<V, U extends A> = V Function(U);
final baz = C<int>((a) {
return a.foo(B(Future.value(0)));
});
main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'dart:async';

abstract class A {
T foo<T>(B<T> b);
}

abstract class D<W> implements A {}

class B<X> {
B(X x);
}

class C<Y> {
C(this.bar);
final Bar<FutureOr<Y>, D<Y>> bar;
}

final baz = C<int>((a) {
return a.foo(B(Future.value(0)));
});
main() {}
typedef Bar<V, U extends A> = V Function(U);
34 changes: 34 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_2.dart.weak.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:async" as asy;

import "dart:async";

typedef Bar<V extends core::Object? = dynamic, contravariant U extends self::A> = (U) → V%;
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
abstract method foo<T extends core::Object? = dynamic>(self::B<self::A::foo::T%> b) → self::A::foo::T%;
}
class B<X extends core::Object? = dynamic> extends core::Object {
constructor •(self::B::X% x) → self::B<self::B::X%>
: super core::Object::•()
;
}
class C<Y extends core::Object? = dynamic> extends core::Object {
final field (self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar;
constructor •((self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar) → self::C<self::C::Y%>
: self::C::bar = bar, super core::Object::•()
;
}
abstract class D<W extends core::Object? = dynamic> extends core::Object implements self::A {
synthetic constructor •() → self::D<self::D::W%>
: super core::Object::•()
;
}
static final field self::C<core::int> baz = new self::C::•<core::int>((self::D<core::int> a) → FutureOr<core::int> {
return a.{self::A::foo}<FutureOr<core::int>>(new self::B::•<FutureOr<core::int>>(asy::Future::value<core::int>(0))){(self::B<FutureOr<core::int>>) → FutureOr<core::int>};
});
static method main() → dynamic {}
34 changes: 34 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_2.dart.weak.modular.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:async" as asy;

import "dart:async";

typedef Bar<V extends core::Object? = dynamic, contravariant U extends self::A> = (U) → V%;
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
abstract method foo<T extends core::Object? = dynamic>(self::B<self::A::foo::T%> b) → self::A::foo::T%;
}
class B<X extends core::Object? = dynamic> extends core::Object {
constructor •(self::B::X% x) → self::B<self::B::X%>
: super core::Object::•()
;
}
class C<Y extends core::Object? = dynamic> extends core::Object {
final field (self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar;
constructor •((self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar) → self::C<self::C::Y%>
: self::C::bar = bar, super core::Object::•()
;
}
abstract class D<W extends core::Object? = dynamic> extends core::Object implements self::A {
synthetic constructor •() → self::D<self::D::W%>
: super core::Object::•()
;
}
static final field self::C<core::int> baz = new self::C::•<core::int>((self::D<core::int> a) → FutureOr<core::int> {
return a.{self::A::foo}<FutureOr<core::int>>(new self::B::•<FutureOr<core::int>>(asy::Future::value<core::int>(0))){(self::B<FutureOr<core::int>>) → FutureOr<core::int>};
});
static method main() → dynamic {}
28 changes: 28 additions & 0 deletions pkg/front_end/testcases/nnbd/issue48631_2.dart.weak.outline.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;

import "dart:async";

typedef Bar<V extends core::Object? = dynamic, contravariant U extends self::A> = (U) → V%;
abstract class A extends core::Object {
synthetic constructor •() → self::A
;
abstract method foo<T extends core::Object? = dynamic>(self::B<self::A::foo::T%> b) → self::A::foo::T%;
}
class B<X extends core::Object? = dynamic> extends core::Object {
constructor •(self::B::X% x) → self::B<self::B::X%>
;
}
class C<Y extends core::Object? = dynamic> extends core::Object {
final field (self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar;
constructor •((self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar) → self::C<self::C::Y%>
;
}
abstract class D<W extends core::Object? = dynamic> extends core::Object implements self::A {
synthetic constructor •() → self::D<self::D::W%>
;
}
static final field self::C<core::int> baz;
static method main() → dynamic
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:async" as asy;

import "dart:async";

typedef Bar<V extends core::Object? = dynamic, contravariant U extends self::A> = (U) → V%;
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
abstract method foo<T extends core::Object? = dynamic>(self::B<self::A::foo::T%> b) → self::A::foo::T%;
}
class B<X extends core::Object? = dynamic> extends core::Object {
constructor •(self::B::X% x) → self::B<self::B::X%>
: super core::Object::•()
;
}
class C<Y extends core::Object? = dynamic> extends core::Object {
final field (self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar;
constructor •((self::D<self::C::Y%>) → FutureOr<self::C::Y%>% bar) → self::C<self::C::Y%>
: self::C::bar = bar, super core::Object::•()
;
}
abstract class D<W extends core::Object? = dynamic> extends core::Object implements self::A {
synthetic constructor •() → self::D<self::D::W%>
: super core::Object::•()
;
}
static final field self::C<core::int> baz = new self::C::•<core::int>((self::D<core::int> a) → FutureOr<core::int> {
return a.{self::A::foo}<FutureOr<core::int>>(new self::B::•<FutureOr<core::int>>(asy::Future::value<core::int>(0))){(self::B<FutureOr<core::int>>) → FutureOr<core::int>};
});
static method main() → dynamic {}
Loading

0 comments on commit 7d8d3bb

Please sign in to comment.