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
Fix #934, though Gavin might not like it #937
Conversation
You're right, I hate it. This is a total layer breaker. There's no way I can possibly know I'm not breaking things when I make changes to the type checker. This kind of logic has to be handled in the back end. |
I can see your point. However, I don't know how the backend can reasonably deal with it. Once the type of the attribute/variable has been inferred the typechecker will go about using it in the rest of its analysis, and that underlying type will be copied all over the model. How am I supposed to handle it in the backend when I don't know where that incorrect type has propagated to? I really don't want to have to reproduce half the logic of the It seems to me we should infer the correct type and in the case of the JVM that means without the underyling type, since we say that |
Well look I told you guys way back when that this was the wrong way to do it, that |
I mean, looking at your proposed fix, it seems to me that this change is required precisely because of totally realsonable recent changes I made to the typechecker that had the totally unexpectable side-effect of breaking the handling of underlyingTypes, which is all essentially based on the unfounded assumption that the typechecker never creates new |
Oh, sorry, that's not right, I misunderstood. The issue is in fact the opposite: that it is remembering the underlying type when it shouldn't be. But the point still stands: the typechecker is incapable of reasoning about underlying types, and engineering this stuff into |
It's the only reasonable place we could have put this! The only common thing that is used all over the place is the type checker tree. Even if we would have made this infrastructure you talk about, how would we make the link between What I do agree with is that we should either a) solve this on our own in the backend or b) come up with some way that backends can inject callbacks to do this kind of work in a completely consistent and transparant way to the typechecker. Because we can't just go arounud inserting random |
Well, like it or not, the underlying type is part of the type, and as such has to be dealt with in the typechecker, because it is tied to |
I don't see how that's true.
Correct. So put the underlying type there.
It's totally mysterious to me why you can't have your own |
Because there's no point in duplicating that class? |
Whhhaaaa? And the point is: separation of concerns, and testability. |
I do agree here. I mean there no "logic" to this change, no seemingly obvious reason why suddenly the typechecker in these particular 4 lines needs to insert a call it knows nothing about but not in dozens of other similar locations. |
There is logic: it's only for declarations of type If we pull |
The logic is simple: When we infer the type (i.e. copy the type from the specifier expression to the attribute declaration) we have to drop the underlying type because the declaration (being a Ceylon declaration) should not have an underlying type (by definition, underlying types should only be coming from stuff loaded by the model loader). The fact is that
|
That's not logic, at least not from the point of the type checker. It's just something that happens to work. But someone working on the typechecker without any knowledge about backend can't know what to do here. And I'm not suggesting changing anything about the current system, I actually agree that PT is the best place for this information for us, but I also think we can't pollute the typechekcer with behaviour that it knows and cares nothing about.
Which was one of my suggestions yes Or maybe there is a way to nicely abstract this information away into PT that makes it official that model loaders (in general) can add extra information to PTs and that from there define it as a rule that that information is lost when assigning or passing it as a parameter, etc. But I can't help but agree with @gavinking that the current fix from his perspective is horrible. (But @gavinking please help us to come up with something that works for you and for us) |
My prediction is that if you rewrite this as a separate visitor, you will discover that suddenly you understand the logic for handling underlying types much better than you do today, and will discover and fix several bugs in the process. I also suspect that it's a very easy job. You would not need to reproduce any of the functionality of |
(I'll repeat this here because I don't know if anyone besides Tom reads the original issue): |
This appears to have been merged manually so I'll close it. |
No description provided.