-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analyzer issues incorrect warning on inconsistent interfaces in mixin inference #34404
Comments
cc @bwilkerson @stereotype441 @yjbanov This doesn't need to be fixed for the old super-mixin inference, but we need to be sure this works correctly with the new syntax since flutter uses this pattern. I'll try to get some tests landed for this. |
FYI, this may have been fixed(?). Not sure though. The errors I see now are:
|
if I change class I<X> {}
class M0<T> implements I<T> {}
class M1<T> implements I<T> {
T foo() => null;
}
// M1 is inferred as M1<int>
class A extends I<int> with M0, M1 {}
void main () {
String s = new A().foo();
} I get this error:
That makes me think the inference may not be working correctly. |
This problem exists even without mixins. class I<T> {}
class A<T> implements I<T> {}
class B implements I<int>, A {} Analyzer reports @leafpetersen Could you please point me at the section in the specification that governs the expected behavior? |
I'll look into this |
This is the relevant reproduction for the new mixin syntax: class I<X> {}
mixin M0<T> on I<T> {}
mixin M1<T> on I<T> {
T foo() => null;
}
class A = I<int> with M0, M1;
void main () {
String s = new A().foo();
} I still see the incorrect error for this example (and actually don't see the correct error). I believe that this case is covered by the tests that I added. |
Note that this will be a blocker for migrating flutter. cc @JekCharlsonYu |
cc @yjbanov |
Thanks for looking into it! Here a place in Flutter where we have to ignore an analyzer warning when inference fails. |
A fix for the repro in #34404 (comment) is out for review: https://dart-review.googlesource.com/c/sdk/+/75625. There are still a few of Leaf's test cases failing, so I'm going to leave this issue open until I've addressed them. |
… and resynthesis. Partially addresses #34404. Change-Id: Ia115647c7e6e15092a7dca55287ff0680b780a97 Reviewed-on: https://dart-review.googlesource.com/75625 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
With 2e3f17f, the analyzer now produces the expected behavior for Leaf's example in #34404 (comment). But that same example fails when the analyzer is run with the "--supermixin" flag is passed in. The example at the top of this bug report also sill fails. @yjbanov's Your example from Flutter is in a similar situation: if I modify it to use "mixin" syntax and analyze it without "--supermixin", it works. But if I analyze it with "--supermixin", it fails (regardless of whether old or new syntax is used). So I think we are no longer blocking flutter's migration to the new syntax. And I'm mindful of Leaf's statement that this doesn't need to be fixed for the old super-mixin inference. But I'm bothered by the fact that the presence of the "--supermixin" flag mysteriously affects the new mixin syntax as well--that really shouldn't happen. So I'm going to continue investigating for a bit longer. |
Aha, glad I checked. Supermixin error checking is still not working, but it looks like it's working because it's disabled when the "--supermixin" flag is missing. So this bug still blocks Flutter's migration to the new syntax. Working on a fix. |
Candidate fix out for review: https://dart-review.googlesource.com/c/sdk/+/75792. This fixes and enables the error checking, and as a bonus, it fixes the test case in the original bug report (that uses the old "--supermixin" syntax). |
The analyzer issues the following warnings on the code below:
Note that the second (expected) error does imply that the mixin inference is succeeding and inferring
int
as the type argument, but nonetheless the first (unexpected) error is emitted as if inference had failed.The text was updated successfully, but these errors were encountered: