Skip to content
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

Resurrect proposed Fix #13553: add Symbol#tpe method #13826

Closed
wants to merge 1 commit into from

Conversation

neko-kai
Copy link
Contributor

@neko-kai neko-kai commented Oct 26, 2021

by @cchantep
This seems to have been erroneously submitted as a feature request and then closed lampepfl/dotty-feature-requests#247
I suspect that simply exposing def tpe: TypeRepr = self.denot.info is sufficient to fix the bulk of the issue, so I'm reopening it as a PR.

@neko-kai neko-kai changed the title Resurrect proposed Fix #13553: add Symbol#tpe method by @cchantep Resurrect proposed Fix #13553: add Symbol#tpe method Oct 26, 2021
@odersky
Copy link
Contributor

odersky commented Oct 26, 2021

I think the consensus was that we should go through the thisType of the owner instead? Is that exposed in the API?

The reason not to have a Symbol#tpe method is not that it's impossible (in fact it is trivial) but that it is wrong in most cases. People will be tempted use this method (because it is so straightforward!) and then be surprised that more advanced cases won't work. We had this happen literally hundreds of times in the compiler. Newbies will fall into this trap with close to 100% probability.

@cchantep
Copy link
Contributor

How it's possible to get a symbol for a TypeRepr using ThisType ?

@odersky
Copy link
Contributor

odersky commented Oct 26, 2021

@cchantep It should be something like

sym.owner.thisType.memberType(sym)

That assumes there is a thisType. I don't know the details. (I only know the compiler).

@cchantep
Copy link
Contributor

@cchantep It should be something like

sym.owner.thisType.memberType(sym)

That assumes there is a thisType. I don't know the details. (I only know the compiler).

And also assume there is already a Symbol, starting from a TypeRepr (or even Type[T]), I don't think that's possible.

@neko-kai
Copy link
Contributor Author

That assumes there is a thisType

Adding thisType would also solve #13553. As is, there's a recommendation in memberType doc to use it with the owner type, but no way to retrieve the owner type except via .tree.tpe

@neko-kai
Copy link
Contributor Author

Fixed in #14124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolve Symbol type
3 participants