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

Typer should preserve aliases in TypeTrees #1181

Closed
smarter opened this issue Mar 18, 2016 · 2 comments
Closed

Typer should preserve aliases in TypeTrees #1181

smarter opened this issue Mar 18, 2016 · 2 comments

Comments

@smarter
Copy link
Member

smarter commented Mar 18, 2016

Or at least, preserve them for aliases whose kind is different from the kind of their right-hand side

object Test {
  def foo[M[_]](x: M[Int]) = x

  type Alias[A] = (A, A)
  val x: Alias[Int] = (1, 2)

  foo[Alias](x) // ok
  foo(x) // ok in scalac but fails in dotty with:
         // error: type mismatch:
         //  found   : (Int, Int)
         //  required: M[Int]
}
@odersky
Copy link
Contributor

odersky commented Mar 18, 2016

I looked into it, and it does not seem to have an easy solution.

@smarter
Copy link
Member Author

smarter commented Mar 18, 2016

Could you expand on that? Why do we dealias here anyway?

odersky added a commit to dotty-staging/dotty that referenced this issue Mar 19, 2016
odersky added a commit to dotty-staging/dotty that referenced this issue Mar 30, 2016
smarter added a commit to dotty-staging/dotty that referenced this issue Jul 18, 2016
Now that we implement partial higher-order unification (SI-2712 fix)
i1181.scala will compile even if `Alias|Int]` gets dealiased to
`(Int, Int)` because we can unify the latter with `M[_]` where
`M = [X] -> (Int, X)`.

The new test will only succeed if `Alias[Int, Int]` is not dealiased
because we will never unify `Foo[Int]` with `M[_,_]`.
smarter added a commit to dotty-staging/dotty that referenced this issue Jul 18, 2016
Now that we implement partial higher-order unification (SI-2712 fix)
i1181.scala will compile even if `Alias[Int]` gets dealiased to
`(Int, Int)` because we can unify the latter with `M[_]` where
`M = [X] -> (Int, X)`.

The new test will only succeed if `Alias[Int, Int]` is not dealiased
because we will never unify `Foo[Int]` with `M[_,_]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants