Closed
Description
With the following three files:
// tobounds_a.dart
class S<T> {}
class Remote<T extends S> {
List<T> get listOfS => [];
List<S> get listOfS2 => [];
}
//tobounds.dart
import 'tobounds_a.dart';
class Local<T extends S> {
List<T> get listOfS => [];
List<S> get listOfS2 => [];
}
class B {
Remote a;
Local b;
void test() {
List l = [];
a.listOfS.addAll(l); // should be warning
b.listOfS.addAll(l); // should be warning
a.listOfS2.addAll(l); // should be warning
b.listOfS2.addAll(l); // should be warning
}
}
//tobounds_client.dart
import 'tobounds_a.dart';
import 'tobounds.dart';
var x = new B();
Analyzing tobounds.dart directly in strong mode yields three of the four expected errors:
[warning] Unsound implicit cast from List<dynamic> to Iterable<S<dynamic>> (/usr/local/google/home/leafp/tmp/tobounds.dart, line 14, col 22)
[warning] Unsound implicit cast from List<dynamic> to Iterable<S<dynamic>> (/usr/local/google/home/leafp/tmp/tobounds.dart, line 15, col 23)
[warning] Unsound implicit cast from List<dynamic> to Iterable<S<dynamic>> (/usr/local/google/home/leafp/tmp/tobounds.dart, line 16, col 23)
3 warnings found.
Analyzing tobounds_client.dart in strong mode yields all four of the expected errors:
[warning] Unsound implicit cast from List<dynamic> to Iterable<S<dynamic>> (/usr/local/google/home/leafp/tmp/tobounds.dart, line 13, col 22)
[warning] Unsound implicit cast from List<dynamic> to Iterable<S<dynamic>> (/usr/local/google/home/leafp/tmp/tobounds.dart, line 14, col 22)
[warning] Unsound implicit cast from List<dynamic> to Iterable<S<dynamic>> (/usr/local/google/home/leafp/tmp/tobounds.dart, line 15, col 23)
[warning] Unsound implicit cast from List<dynamic> to Iterable<S<dynamic>> (/usr/local/google/home/leafp/tmp/tobounds.dart, line 16, col 23)
[hint] Unused import (/usr/local/google/home/leafp/tmp/tobounds_client.dart, line 1, col 8)
4 warnings and 1 hint found.
Removing the unused import in tobounds_client.dart causes the fourth expected error not to be reported again.