diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala | 2 | ||||
-rw-r--r-- | test/files/run/phantomValueClass.check | 1 | ||||
-rw-r--r-- | test/files/run/phantomValueClass.scala | 10 |
3 files changed, 12 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index 5104518dd9..3515c1d521 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -68,7 +68,7 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { private def normalize(stpe: Type, clazz: Symbol): Type = stpe match { case PolyType(tparams, restpe) => - GenPolyType(tparams dropRight clazz.typeParams.length, normalize(restpe, clazz)) + GenPolyType(tparams dropRight clazz.typeParams.length, normalize(restpe.substSym(tparams takeRight clazz.typeParams.length, clazz.typeParams), clazz)) case MethodType(tparams, restpe) => restpe case _ => diff --git a/test/files/run/phantomValueClass.check b/test/files/run/phantomValueClass.check new file mode 100644 index 0000000000..323fae03f4 --- /dev/null +++ b/test/files/run/phantomValueClass.check @@ -0,0 +1 @@ +foobar diff --git a/test/files/run/phantomValueClass.scala b/test/files/run/phantomValueClass.scala new file mode 100644 index 0000000000..f6509f2189 --- /dev/null +++ b/test/files/run/phantomValueClass.scala @@ -0,0 +1,10 @@ +final class Phantom[A](val s: String) extends AnyVal { + def compose(p: Phantom[A]): Phantom[A] = new Phantom[A](s+p.s) +} + +object Test extends App { + val x = new Phantom[Int]("foo") + val y = new Phantom[Int]("bar") + val z = x compose y + println(z.s) +} |