Issue 40764. Use Never instead of Null when converting super-bounded to regular-bounded.

Bug: https://github.com/dart-lang/sdk/issues/40764
Change-Id: I58f0e9860dd000aa2d8e416c5fce7e8964db0ef8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137280
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
Konstantin Shcheglov 2020-02-26 20:12:51 +00:00 committed by commit-bot@chromium.org
parent 9eeecae3e4
commit 0c7b9cf470
4 changed files with 26 additions and 1 deletions

View file

@ -82,7 +82,7 @@ class DynamicTypeImpl extends TypeImpl {
DartType replaceTopAndBottom(TypeProvider typeProvider,
{bool isCovariant = true}) {
if (isCovariant) {
return typeProvider.nullType;
return NeverTypeImpl.instance;
} else {
return this;
}

View file

@ -450,6 +450,14 @@ class B extends A {}
main() {
foo<B, A>();
}
''');
}
test_superBounded() async {
await assertNoErrorsInCode(r'''
class A<X extends A<X>> {}
A get foo => throw 0;
''');
}
}

View file

@ -0,0 +1,12 @@
# Feature tests for instantiation to bounds, and super-bounded types
This directory was created in order to hold tests pertaining to the
Dart feature _instantiate to bound_, which provides inference of
default values for omitted type arguments. In order to handle
F-bounded type parameters without introducing infinite types, this
feature relies on another feature, _super-bounded types_, which is
therefore also in focus for tests in this directory. For more details,
please check the feature specifications on
[super-bounded types](https://github.com/dart-lang/sdk/blob/master/docs/language/informal/super-bounded-types.md)
and on
[instantiate to bound](https://github.com/dart-lang/sdk/blob/master/docs/language/informal/instantiate-to-bound.md).

View file

@ -0,0 +1,5 @@
class A<X extends A<X>> {}
A get g => throw 0;
main() {}