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

Structural types do not inspect bounds; unsoundness results #5378

Closed
scabug opened this issue Jan 16, 2012 · 8 comments
Closed

Structural types do not inspect bounds; unsoundness results #5378

scabug opened this issue Jan 16, 2012 · 8 comments

Comments

@scabug
Copy link

scabug commented Jan 16, 2012

Ring the big bell.

class Coll[+T] {
  def contains = new { def apply[T1 <: T](value: T1) = ??? }
}

object Test {
  def main(args: Array[String]): Unit = {
    val xs = new Coll[List[String]]
    val ys: Coll[Traversable[String]] = xs
    
    println(ys contains Nil)
    // java.lang.NoSuchMethodException: Coll$$anon$1.apply(scala.collection.Traversable)
    //  at java.lang.Class.getMethod(Class.java:1605)
    //  at Test$.reflMethod$Method1(a.scala:14)
    //  at Test$.main(a.scala:14)
    //  at Test.main(a.scala)
  }
}

It should fail the way this does:

def contains = new { def apply(value: T) = ??? } 

./a.scala:2: error: Parameter type in structural refinement may not refer to an abstract type defined outside that refinement
  def contains = new { def apply(value: T) = ??? } 
                           ^
one error found
@scabug
Copy link
Author

scabug commented Jan 16, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5378?orig=1
Reporter: @paulp
Affected Versions: 2.10.0
See #967, #5517

@scabug
Copy link
Author

scabug commented Jan 16, 2012

@paulp said:
You really want this one? It'll take me five minutes to fix it, I was just letting it age under scala reviewer for a minute.

@scabug
Copy link
Author

scabug commented Jan 16, 2012

@adriaanm said:
please, have at it!

@scabug
Copy link
Author

scabug commented May 9, 2012

@phaller said:
Added test in 71c17a649e.

@scabug
Copy link
Author

scabug commented Jan 2, 2013

@paulp said:
Patch pending.

@scabug
Copy link
Author

scabug commented Jan 22, 2013

@adriaanm said:
TODO: backport 31f073c0eb to 2.10.x

@scabug
Copy link
Author

scabug commented Jan 28, 2013

@adriaanm said (edited on Jan 28, 2013 11:07:14 PM UTC):
2.11: scala/scala#1873
2.10.1: scala/scala#2000

@scabug
Copy link
Author

scabug commented Feb 1, 2013

@paulp said:
110b54a575278

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