From 3898deafe17eaf5e96387d02c58e4cc74f90838f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 20 Oct 2015 16:38:16 +0200 Subject: Fix #815. Need to handle hk-aliases specially in typedNew --- src/dotty/tools/dotc/typer/Typer.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') 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) -- cgit v1.2.3