Skip to content

Singleton types are erased at display. #43

@tribbloid

Description

@tribbloid

Here is a simple example:


    val a = 1
    val b = 2

    implicitly[a.type =:= b.type]

Generates the error::

[Error] /......:46: implicit error;
!I e (Cannot prove that a.type =:= b.type.): Int =:= Int
one error found

The first section Cannot prove that a.type =:= b.type is a customised implicitNotFound message, which is helpful, the second part Int =:= 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:

-+ a.type =:= b.type
 :       `-+ [ 2 ARGS ] :
 :         !-+ a.type .................................................................................................................. [0]
 :         : !-+ Int ..................................................................................................................... [1]
 :         :   !-+ AnyVal
 :         :     !-- Any ..................................................................................................................... [2]
 :         !-+ b.type .................................................................................................................. [3]
 :           !-- Int ..................................................................................................................... [1]
 !-+ a.type <:< b.type
   :       `-+ [ 2 ARGS ] :
   :         !-- a.type .................................................................................................................. [0]
   :         !-- b.type .................................................................................................................. [3]
   !-+ java.io.Serializable
   : !-- Any ..................................................................................................................... [2]
   !-+ a.type => b.type
     :       `-+ [ 2 ARGS ] :
     :         !-- a.type .................................................................................................................. [0]
     :         !-- b.type .................................................................................................................. [3]

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions