-
Notifications
You must be signed in to change notification settings - Fork 26
Infer parameter types #105
Comments
@leafpetersen @vsmenon dumb question: isn't it perfectly safe to override I'm even more confused by [edit: fixed to use |
@vsmenon Regarding inference, we initially didn't want to do inference of dynamic on the arguments of subclasses because this was a valid override and we were only doing inference if not doing so would have yielded an invalid override error. We could add inference as well, but I honestly would like this override to be allowed too. |
@jmesserly you are correct. void operator [](name, value) I really meant void operator [](K name, V value) If i want to the method to have a different signature than the base class I could always write void operator [](dynamic name, dynamic value) |
I filed an issue for the typing bug (#107). We can keep this issue on whether or when we should infer parameter types. |
One counterexample of sorts: class A { class B { Our current behavior allows this. Typing foo as Object->void would not. |
Is this issue still open? |
Yep. This is dependent on either folding the inference into the checker or doing it before the checker runs, which is on my todo list. |
Note, this is coming up frequently in angular runs: https://travis-ci.org/angular/angular/jobs/75265458 E.g.,
The omitted parameter types in the override could be inferred as |
Currently we infer return types but not parameter types.
We will have an easiest to explain story for users if we infer both.
Example errors currently reported if parameter types are omitted in a subclass. Technically these errors shouldn't occur but in practice I think they are good as they match the user intent that a subclass rarely intentionally uses a less specific type than the base class.
Repro source code diff to fix these errors:
For example, consider the following diff required to fix:
The text was updated successfully, but these errors were encountered: