Open gavinking opened 9 years ago
Actually there's a bug here that I didn't know about: in fun<T>(T x)
the <T>
gets treated as a type argument list. Which results in the typechecker actually accepting this code:
T fun<T>(T x);
fun<String>(String x) => x;
Oops!
OK, so this one, it turns out is really tricky, due to something rubbish in the model that is probably the source of other bugs that I'm surprised we have not run into yet.
Basically, in DeclarationVisitor
, the Parameter
s and TypeParameter
s belonging to a specification statement wind up getting their parent declaration
set to point to the innermost containing declaration, since the Specification
itself doesn't count as a Declaration
.
This means that we can wind up with a bunch of models with the same names and parents which really screws up the equals()
and hashCode()
of at least TypeParameter
.
Something needs to be done to fix this, since it's really super-fragile right now.
Currently we don't let you write:
Nor do we let you use the shortcut refinement syntax for generic methods.
I think this is a limitation that should be removed, assuming it's not impossible to parse.