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

existentials in structural type signatures #4867

Open
scabug opened this issue Aug 2, 2011 · 1 comment
Open

existentials in structural type signatures #4867

scabug opened this issue Aug 2, 2011 · 1 comment

Comments

@scabug
Copy link

scabug commented Aug 2, 2011

This works:

scala> var x: AnyVal { def *(other: Int): Int } = _
x: AnyVal{def *(other: Int): Int} = null

scala> x = 5
x: AnyVal{def *(other: Int): Int} = 5

This doesn't, nor obviously does any more useful attempt to apply existentials (more useful than the Int identity that is.)

scala> var x: AnyVal { def *(other: T forSome { type T >: Int <: Int }): Int } = _
x: AnyVal{def *(other: T forSome { type T >: Int <: Int }): Int} = null

scala> x = 5
<console>:8: error: type mismatch;
 found   : Int(5)
 required: AnyVal{def *(other: T forSome { type T >: Int <: Int }): Int}
       x = 5
           ^

Putting the shoe back on the other foot, this works:

scala> type SomeT[Bound] = T forSome { type T >: Bound <: Bound }
defined type alias SomeT

scala> var x: AnyVal { def *(other: SomeT[Int]): Int } = _
x: AnyVal{def *(other: SomeT[Int]): Int} = null

scala> x = 5
x: AnyVal{def *(other: SomeT[Int]): Int} = 5

So there are a lot of interesting questions here, but there is little doubt that at the least, it is a bug that it works with an alias but not by skipping the alias and using the identical expansion.

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

1 participant