Skip to content

Can't prove equality between syntactically equal type aliases to an existential type #10556

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

Open
sir-wabbit opened this issue Oct 19, 2017 · 2 comments

Comments

@sir-wabbit
Copy link

sir-wabbit commented Oct 19, 2017

trait R[Y] { type T }
type A = a.T forSome { val a: R[Y]; type Y }
type B = a.T forSome { val a: R[Y]; type Y }
final case class Equal[A, B >: A <: A]()
Equal[A, B] // doesn't compile
implicitly[A =:= B] // doesn't compile

Tested in 2.11 on ScalaFiddle and 2.12.1 in REPL.

@sir-wabbit sir-wabbit changed the title Can't prove equality between syntactically equal type aliases Can't prove equality between syntactically equal type aliases to an existential type Oct 19, 2017
@milessabin
Copy link

There is a problem, but I don't think it's quite what the headline describes. For instance, the following, which I think is equivalent to what you intended above, is just fine,

scala> type A = a.T forSome { val a: R[_]}
defined type alias A

scala> type B = a.T forSome { val a: R[_]}
defined type alias B

scala> implicitly[A =:= B]
res13: A =:= B = <function1>

@sir-wabbit
Copy link
Author

This might be related:

val x = "a"
type X = a.type forSome { val a: x.type; type X }
implicitly[X =:= x.type]

compiles

val x = "a"
type X = a.type forSome { val a: x.type; type X >: a.type <: a.type }
implicitly[X =:= x.type]

doesn't

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

No branches or pull requests

2 participants