-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.dart-model-analyzer-specIssues with the analyzer's implementation of the language specIssues with the analyzer's implementation of the language spectype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
Here, the call to f should be valid and inferrable as Cloneable<T>
.
class Clonable<T> {}
class SubClonable<T> extends Clonable<T> {
T m(T t) => t;
}
void f<T extends Clonable<T>>(T object) {
if (object is SubClonable<T>) {
f(object);
}
}
However it fails in analyzer and CFE. This is the analyzer ticket for this issue. (CFE is #35800)
It's critical to note that object
is promoted to type T' extends SubCloneable<T>
. So if the analyzer attempts to infer SubClonable<T>
for T
in f(object)
, then that will fail. However, it should be possible to infer Clonable, which in fact works when typed explicitly.
May be related to #35100
srawlins and FMorschel
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.dart-model-analyzer-specIssues with the analyzer's implementation of the language specIssues with the analyzer's implementation of the language spectype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)