Skip to content

Commit 73f725c

Browse files
committed
Merge pull request #832 from dotty-staging/fix-#815-hk-constructor-alias
Fix #815.
2 parents 344f849 + 3898dea commit 73f725c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
345345
val clsDef = TypeDef(x, templ).withFlags(Final)
346346
typed(cpy.Block(tree)(clsDef :: Nil, New(Ident(x), Nil)), pt)
347347
case _ =>
348-
val tpt1 = typedType(tree.tpt)
348+
var tpt1 = typedType(tree.tpt)
349+
if (tpt1.tpe.isHK) {
350+
val deAliased = tpt1.tpe.dealias.EtaReduce
351+
if (deAliased.exists && deAliased.ne(tpt1.tpe))
352+
tpt1 = tpt1.withType(deAliased)
353+
}
349354
checkClassTypeWithStablePrefix(tpt1.tpe, tpt1.pos, traitReq = false)
350355
assignType(cpy.New(tree)(tpt1), tpt1)
351356
// todo in a later phase: checkInstantiatable(cls, tpt1.pos)

tests/pos/i815.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.collection.immutable.::
2+
class C[T](x: T)
3+
object A {
4+
def main(args: Array[String]): Unit = {
5+
val x = new C("A")
6+
val y = new ::(args, Nil)
7+
val z = ::(args, Nil)
8+
println(y)
9+
println(z)
10+
}
11+
}

0 commit comments

Comments
 (0)