blob: e1ae3c4a69e7c7705c113dba03812d636cc70df7 [file] [log] [blame]
// Copyright (c) 2019, 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.
// @dart=2.9
class A {}
class B {}
class C extends B implements A {}
List<A> list;
List<T> g<T extends A>(T t) {
list = <T>[];
print(list.runtimeType);
return list;
}
List<S> f<S>(S s) {
if (s is A) {
var list = g(s);
return list;
}
return null;
}
main() {
f<B>(new C());
print(list.runtimeType);
List<A> aList;
aList = list;
Object o = aList;
expectThrows(() => aList = o);
}
expectThrows(f()) {
bool hasThrown = true;
try {
f();
hasThrown = false;
} catch(e) {}
if (!hasThrown) {
throw "Expected the function to throw";
}
}