-
Notifications
You must be signed in to change notification settings - Fork 28
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
Singleton types are erased at display. #43
Comments
interesting find! you can add a you will need to add the do you need directions for setting up a unit test? |
So It should be a 'SingleTypeFormatter' that handles The difficult part would be to find the code where the 'erasure' from a.type to Int happens: the code is displaying The equally difficult part would be adding the parameter to display inheritance & ARG tree for All kinds of Formatted, not just UniqueSingleType. Should it be considered later for being too complex ? BTW, this tree can be quite long and complex, but does covers all the edge cases when an implicit search fails. E.g. for a record type in shapeless:
It's tree is:
|
Not quite sure I know what the proper behaviour here would be – is
What do you mean by "adding the parameter"? Do you want to have an option that toggles displaying the trees for all types? |
@tek I'm quite sure
Yes That's my intention, otherwise the fix for the singleton types will make the |
Wouldn't the tree algorithm work entirely on the root type? You could just check the option in |
@tek sounds good, already implemented. How about my first question? Namely, how to avoid Also I'm trying to run the test in my IDE (IntelliJ IDEA, not through sbt), I always got the following error:
Any idea what could be the cause? |
regarding the erasure, I would start by debug printing the type in a function like as for these errors: the tests use a |
Thanks a lot, made it temporarily working in IDEA by the following monkey patch:
Need to synchronise version with build file or discover the jar name automatically tho |
oh, huh. I would assume that the cause of this could be that the tests are executed in a different sbt scope by IntelliJ. If you can find out how it works please advise! |
OK fixed without tree-visualizing capability I saw a lot of idiosyncratic black magic for type symbol manipulation. I'm afraid some of them needs a more generalisable overhaul. Some of them are quite far from scala convention. The simpliest & safest way to avoid erasing information is to display 2 Strings: 1 from scala team (tpe.toString directly) & 1 from you |
I have to add some type annotation to avoid the 2.13 compiler from inferring singleton type automatically Regardless, the only significant change I made is to use type.toString and type.prefixString directly, instead of type.typeSymbol and type.termSymbol. These implementations are incrementally & carelessly patched by a series of PhD students, I don't have a lot of faith in them |
yes, I made it up as I went along 🙂 since the tests succeed, do you want it merged now or do you want to supply part 2 first? |
If you think all the changes make sense then let's merge it, always easier to have many decoupled commits instead of a big one. I'll need some time to figure out how to embed a tree with interlinked references (those ............ [1] notations) into a type display |
sounds good! |
Here is a simple example:
Generates the error::
The first section
Cannot prove that a.type =:= b.type
is a customised implicitNotFound message, which is helpful, the second partInt =:= Int
is added by splain, which is clueless.If the ImplicitNotFound message hasn't been defined, or it is buried deep in a chain implicit resolution tree, there will be no way to figure out the cause.
My proposed fix is to show the full inheritance tree for not just the type, but all its parameters, e.g. for type
a.type =:= b.type
, the result should look like this:I already have the code extract the tree, I just don't know where to inject into your library. Could you point me to the right part of your code?
The text was updated successfully, but these errors were encountered: