scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Duplicators name resolution => fail #8473

Open scabug opened 10 years ago

scabug commented 10 years ago

The duplicator seems to rely on name resoltion instead of patching up ValDef tpt symbols:

$ cat error.scala 
package miniboxing.tests.compile

class G

class RT3[@specialized U, G](g: G) {
  def foo[X](x: X) = ???
  def test(u: U) =
    foo(g)
}
$ scalac_210 error.scala 
error.scala:8: error: type mismatch;
 found   : G(in class RT3$mcB$sp)
 required: miniboxing.tests.compile.G
    foo(g)
        ^
one error found
$ scalac_211 error.scala 
error.scala:8: error: type mismatch;
 found   : G(in class RT3$mcB$sp)
 required: miniboxing.tests.compile.G
    foo(g)
        ^
error: Concrete method has no definition: override <specialized> def test$mcB$sp(u: Byte): Nothing
error: Concrete method has no definition: override <specialized> def test$mcC$sp(u: Char): Nothing
error: Concrete method has no definition: override <specialized> def test$mcD$sp(u: Double): Nothing
error: Concrete method has no definition: override <specialized> def test$mcF$sp(u: Float): Nothing
error: Concrete method has no definition: override <specialized> def test$mcI$sp(u: Int): Nothing
error: Concrete method has no definition: override <specialized> def test$mcJ$sp(u: Long): Nothing
error: Concrete method has no definition: override <specialized> def test$mcS$sp(u: Short): Nothing
error: Concrete method has no definition: override <specialized> def test$mcV$sp(u: scala.runtime.BoxedUnit): Nothing
error: Concrete method has no definition: override <specialized> def test$mcZ$sp(u: Boolean): Nothing
10 errors found

Yet, if class G is commented out, everything works correctly (don't forget to clean up the classpath)

$ cat error2.scala 
package miniboxing.tests.compile

// class G

class RT3[@specialized U, G](g: G) {
  def foo[X](x: X) = ???
  def test(u: U) =
    foo(g)
}
$ rm -rf miniboxing/
$ scalac_210 error2.scala 
$ rm -rf miniboxing/
$ scalac_211 error2.scala 
$

This bug also affects miniboxing: https://github.com/miniboxing/miniboxing-plugin/issues/84

scabug commented 10 years ago

Imported From: https://issues.scala-lang.org/browse/SI-8473?orig=1 Reporter: @VladUreche

scabug commented 10 years ago

@VladUreche said: Fixed in miniboxing: https://github.com/miniboxing/miniboxing-plugin/commit/82eb9a3458e57a7b78da1d84fa43c86e929716a5