diff options
author | Martin Odersky <odersky@gmail.com> | 2015-10-20 16:38:16 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-10-20 16:52:05 +0200 |
commit | 3898deafe17eaf5e96387d02c58e4cc74f90838f (patch) | |
tree | 46b81dcf586b1dc21bc841cab394bb61839ef6e7 | |
parent | cbb565a436196b102c27688d1da8f27bea12bae4 (diff) | |
download | dotty-3898deafe17eaf5e96387d02c58e4cc74f90838f.tar.gz dotty-3898deafe17eaf5e96387d02c58e4cc74f90838f.tar.bz2 dotty-3898deafe17eaf5e96387d02c58e4cc74f90838f.zip |
Fix #815.
Need to handle hk-aliases specially in typedNew
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 7 | ||||
-rw-r--r-- | tests/pos/i815.scala | 11 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index fbdfef930..a8e615246 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -347,7 +347,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val clsDef = TypeDef(x, templ).withFlags(Final) typed(cpy.Block(tree)(clsDef :: Nil, New(Ident(x), Nil)), pt) case _ => - val tpt1 = typedType(tree.tpt) + var tpt1 = typedType(tree.tpt) + if (tpt1.tpe.isHK) { + val deAliased = tpt1.tpe.dealias.EtaReduce + if (deAliased.exists && deAliased.ne(tpt1.tpe)) + tpt1 = tpt1.withType(deAliased) + } checkClassTypeWithStablePrefix(tpt1.tpe, tpt1.pos, traitReq = false) assignType(cpy.New(tree)(tpt1), tpt1) // todo in a later phase: checkInstantiatable(cls, tpt1.pos) diff --git a/tests/pos/i815.scala b/tests/pos/i815.scala new file mode 100644 index 000000000..bc0083ee2 --- /dev/null +++ b/tests/pos/i815.scala @@ -0,0 +1,11 @@ +import scala.collection.immutable.:: +class C[T](x: T) +object A { + def main(args: Array[String]): Unit = { + val x = new C("A") + val y = new ::(args, Nil) + val z = ::(args, Nil) + println(y) + println(z) + } +} |