Open MichaelRFairhurst opened 5 years ago
Note: there is a test in the analyzer codebase that should be re-enabled when this bug is fixed: https://dart-review.googlesource.com/c/sdk/+/90880/4/pkg/analyzer/test/src/task/strong/checker_test.dart#3989
I'm not convinced that this issue should be considered as a bug in the analyzer, it is probably about the type inference algorithm. I created https://github.com/dart-lang/language/issues/3009 for that.
So, just to help out a bit, as for what I found:
https://github.com/dart-lang/sdk/issues/52117 https://github.com/dart-lang/sdk/issues/56028 (this is potentially the solution for the other two)
Are all possibly related?
@FMorschel, thanks for looking into those potential connections!
I do think there is a connection between dart-lang/sdk#52117 and #52077 and dart-lang/sdk#56028, they are all about extensions and intersection types.
However, there is probably no connection to this issue, where the topic is F-bounded type variables and inference (with no references to intersection types or extensions at all).
Sorry about my ignorance. I just thought they were connected because in https://github.com/dart-lang/sdk/issues/52117 there is also a suggestion in https://github.com/dart-lang/sdk/issues/52117 that sounded to me similar to this issue.
No problem, it is not always easy to see whether or not there is a connection!
Here, the call to f should be valid and inferrable as
Cloneable<T>
.However it fails in analyzer and CFE. This is the analyzer ticket for this issue. (CFE is #35800)
It's critical to note that, which in fact works when typed explicitly.
object
is promoted to typeT' extends SubCloneable<T>
. So if the analyzer attempts to inferSubClonable<T>
forT
inf(object)
, then that will fail. However, it should be possible to infer ClonableMay be related to #35100