Skip to content

Missing checks for existential types leads to unsoundness #583

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

Closed
smarter opened this issue May 17, 2015 · 2 comments
Closed

Missing checks for existential types leads to unsoundness #583

smarter opened this issue May 17, 2015 · 2 comments

Comments

@smarter
Copy link
Member

smarter commented May 17, 2015

this should not compile:

import scala.collection.mutable.ListBuffer

object Test {
  def main(args: Array[String]): Unit = {
    val f: ListBuffer[Int] = ListBuffer(1,2)
    val g: ListBuffer[Double] = ListBuffer(3.0,4.0)
    val lb: ListBuffer[ListBuffer[_ <: AnyVal]] = ListBuffer(f, g)
    lb(0)(0) = lb(1)(0)
    val x: Int = f(0) // ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
  }
}

In scalac it fails with:

t583.scala:8: error: type mismatch;
 found   : (some other)_$1(in method main) where type (some other)_$1(in method main) <: AnyVal
 required: _$1(in method main) where type _$1(in method main) <: AnyVal
    lb(0)(0) = lb(1)(0)
                    ^
one error found
@odersky
Copy link
Contributor

odersky commented May 20, 2015

Yes, there's some logic that still needs to be implemented here.

@smarter
Copy link
Member Author

smarter commented Jul 4, 2015

Fixed in #599.

@smarter smarter closed this as completed Jul 4, 2015
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