mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
Reland "Test that the result of instantiate-to-bounds is appropriately checked for super-boundedness."
This is a reland of7419667d67
I reverted this CL in https://dart-review.googlesource.com/c/sdk/+/77520 because I thought it had broken a bunch of bots. It turns out that the bots weren't broken; they were just erroneously reporting a breakage because some change-detection code had noticed that there were new failing tests, and there is not yet a way to tell the change-detection code that the failures are expected. Original change's description: > Test that the result of instantiate-to-bounds is appropriately checked for super-boundedness. > > When I implemented super-boundedness for the analyzer in >b1a54154f8
, very little test status > changed, indicating we didn't have much test coverage for verifying > that the result of instantiate-to-bounds was appropriately checked for > super-boundedness. This CL fills in the coverage gap. > > Change-Id: I8f6fbb3aa4cae1e62861b5eddb113ee9b4bb085c > Reviewed-on: https://dart-review.googlesource.com/77010 > Commit-Queue: Paul Berry <paulberry@google.com> > Auto-Submit: Paul Berry <paulberry@google.com> > Reviewed-by: Erik Ernst <eernst@google.com> Change-Id: Ic84321e928aaf4c6533e6cf5b9d521a1da77dba7 Reviewed-on: https://dart-review.googlesource.com/c/77660 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
0016f80467
commit
49f36b0b2d
2 changed files with 149 additions and 0 deletions
143
tests/language_2/instantiate_to_bounds_super_bounded_test.dart
Normal file
143
tests/language_2/instantiate_to_bounds_super_bounded_test.dart
Normal file
|
@ -0,0 +1,143 @@
|
|||
// Copyright (c) 2018, 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.
|
||||
|
||||
// Verify that when a super-bounded type is produced by instantiate-to-bounds,
|
||||
// it's properly allowed or rejected depending on the context in which it's
|
||||
// used.
|
||||
|
||||
// Raw `A` will be instantiated to `A<B<dynamic>>`, which is super-bounded.
|
||||
class A<T extends B<T>> extends Base {
|
||||
const A();
|
||||
}
|
||||
|
||||
class B<T> {}
|
||||
|
||||
class Base {
|
||||
const Base();
|
||||
|
||||
factory Base.test() = A; //# 01: compile-time error
|
||||
}
|
||||
|
||||
typedef void OldStyleTypedef<T>();
|
||||
|
||||
typedef NewStyleTypedef<T> = void Function();
|
||||
|
||||
void genericFunction<T>() {}
|
||||
|
||||
mixin Mixin {}
|
||||
|
||||
class C {
|
||||
dynamic field;
|
||||
|
||||
void genericMethod<T>() {}
|
||||
|
||||
A test; //# 02: ok
|
||||
|
||||
A test() {} //# 03: ok
|
||||
|
||||
void test(A param()) {} //# 04: ok
|
||||
|
||||
void test(A param) {} //# 05: ok
|
||||
|
||||
void test([A param]) {} //# 06: ok
|
||||
|
||||
void test({A param}) {} //# 07: ok
|
||||
|
||||
C(A param()); //# 08: ok
|
||||
|
||||
C(A this.field); //# 09: ok
|
||||
|
||||
C(A param); //# 10: ok
|
||||
|
||||
C([A param]); //# 11: ok
|
||||
|
||||
C({A param}); //# 12: ok
|
||||
}
|
||||
|
||||
class Test extends B<A> {} //# 13: ok
|
||||
|
||||
class Test extends A {} //# 14: compile-time error
|
||||
|
||||
class Test implements A {} //# 15: compile-time error
|
||||
|
||||
class Test extends Object with A {} //# 16: compile-time error
|
||||
|
||||
class Test = A with Mixin; //# 17: compile-time error
|
||||
|
||||
class Test = Object with Mixin implements A; //# 18: compile-time error
|
||||
|
||||
class Test = Object with A; //# 19: compile-time error
|
||||
|
||||
mixin Test implements A {} //# 20: compile-time error
|
||||
|
||||
mixin Test on A {} //# 21: compile-time error
|
||||
|
||||
A test; //# 22: ok
|
||||
|
||||
A test() {} //# 23: ok
|
||||
|
||||
void test(A param()) {} //# 24: ok
|
||||
|
||||
void test(A param) {} //# 25: ok
|
||||
|
||||
void test([A param]) {} //# 26: ok
|
||||
|
||||
void test({A param}) {} //# 27: ok
|
||||
|
||||
typedef A Test(); //# 28: ok
|
||||
|
||||
typedef void Test(A param()); //# 29: ok
|
||||
|
||||
typedef void Test(A param); //# 30: ok
|
||||
|
||||
typedef void Test([A param]); //# 31: ok
|
||||
|
||||
typedef void Test({A param}); //# 32: ok
|
||||
|
||||
typedef Test = A Function(); //# 33: ok
|
||||
|
||||
typedef Test = void Function(A param); //# 34: ok
|
||||
|
||||
typedef Test = void Function(A); //# 35: ok
|
||||
|
||||
typedef Test = void Function([A param]); //# 36: ok
|
||||
|
||||
typedef Test = void Function([A]); //# 37: ok
|
||||
|
||||
typedef Test = void Function({A param}); //# 38: ok
|
||||
|
||||
void f(dynamic x) {
|
||||
void localFunction<T>() {}
|
||||
|
||||
g(x as A); //# 39: ok
|
||||
g(x is A); //# 40: ok
|
||||
try {} on A catch (_) {} //# 41: ok
|
||||
for (A test in [x]) {} //# 42: ok
|
||||
A test; //# 43: ok
|
||||
OldStyleTypedef<A> test; //# 44: ok
|
||||
NewStyleTypedef<A> test; //# 45: ok
|
||||
genericFunction<A>(); //# 46: ok
|
||||
new C().genericMethod<A>(); //# 47: ok
|
||||
localFunction<A>(); //# 48: ok
|
||||
A test() {} //# 49: ok
|
||||
void test(A param()) {} //# 50: ok
|
||||
void test(A param) {} //# 51: ok
|
||||
void test([A param]) {} //# 52: ok
|
||||
void test({A param}) {} //# 53: ok
|
||||
void Function(A param) test; //# 54: ok
|
||||
void Function(A) test; //# 55: ok
|
||||
void Function([A param]) test; //# 56: ok
|
||||
void Function([A]) test; //# 57: ok
|
||||
void Function({A param}) test; //# 58: ok
|
||||
A(); //# 59: compile-time error
|
||||
new A(); //# 60: compile-time error
|
||||
const A(); //# 61: compile-time error
|
||||
const test = A(); //# 62: compile-time error
|
||||
}
|
||||
|
||||
void g(dynamic x) {}
|
||||
|
||||
main() {
|
||||
f(null);
|
||||
}
|
|
@ -216,6 +216,12 @@ f_bounded_quantification_test/01: MissingCompileTimeError # Issue 33308
|
|||
f_bounded_quantification_test/02: MissingCompileTimeError # Issue 33308
|
||||
generic_methods_bounds_test/01: MissingCompileTimeError # Issue 33308
|
||||
generic_methods_recursive_bound_test/02: MissingCompileTimeError # Issue 33308
|
||||
instantiate_to_bounds_super_bounded_test/14: MissingCompileTimeError # Issue 33308
|
||||
instantiate_to_bounds_super_bounded_test/15: MissingCompileTimeError # Issue 33308
|
||||
instantiate_to_bounds_super_bounded_test/17: MissingCompileTimeError # Issue 33308
|
||||
instantiate_to_bounds_super_bounded_test/18: MissingCompileTimeError # Issue 33308
|
||||
instantiate_to_bounds_super_bounded_test/20: MissingCompileTimeError # Issue 33308
|
||||
instantiate_to_bounds_super_bounded_test/21: MissingCompileTimeError # Issue 33308
|
||||
issue31596_super_test/02: MissingCompileTimeError # Issue 31596
|
||||
issue31596_super_test/04: MissingCompileTimeError # Issue 31596
|
||||
issue34488_test/01: MissingCompileTimeError # Issue 34488
|
||||
|
|
Loading…
Reference in a new issue