-
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
Strong mode override inference not checked against initializer #25546
Comments
also, if the RHS was correctly typed, it should push the type down via inference. |
I'm not sure what the correct behavior is. Do we want to set the type of B.map to the type inferred for the literal ( |
@vsmenon @leafpetersen Thoughts? |
I believe that this is almost (but perhaps not entirely) stale. I cannot reproduce this exactly in bleeding edge (nor the most recent dev release). What I would expect to happen is the following:
Step 2 is not happening. For this example, it doesn't really matter, because upwards inference fills in a type for the literal, and then we reject the program because the two types don't match. However, for this modified example it matters: abstract class A {
Map<int, List<int>> get map;
}
num n;
class B extends A {
var map = { 42: [] };
}
class C extends A {
get map => { 43: [] };
} If I print out the types inferred for everything, it looks like C.map is correctly pushing the inferred type down into the literal, filling in the types as Poking around at this basically got me to the point where the fix looks obvious, so I'll claim this. |
This code should show an error in strong mode - B's map breaks A's contract.
The text was updated successfully, but these errors were encountered: