diff options
author | Martin Odersky <odersky@gmail.com> | 2015-02-28 13:56:22 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-02-28 14:01:11 +0100 |
commit | 83d435640e0a2645256bc588306fdeef1d5799a2 (patch) | |
tree | 389512ec23093072ee57c4559a3260bfe3816f49 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 4e9987740f206c2376957d08d626f7c1ed087688 (diff) | |
download | dotty-83d435640e0a2645256bc588306fdeef1d5799a2.tar.gz dotty-83d435640e0a2645256bc588306fdeef1d5799a2.tar.bz2 dotty-83d435640e0a2645256bc588306fdeef1d5799a2.zip |
Fix bug which prevented New over type-instantiated aliases.
Previously,
type Map = HashMap[Int, String]
new Map
did not work. See test aliasNew.scala for a test.
Formerly this logic handled in Parsers (wrapNew),
but that one does not work for aliastypes.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index e25e73a2c..76a9dbfdc 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -347,8 +347,8 @@ 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) - checkClassTypeWithStablePrefix(tpt1.tpe, tpt1.pos, traitReq = false) + val tpt1 = typedType(tree.tpt) + checkClassTypeWithStablePrefix(tpt1.tpe, tpt1.pos, traitReq = false) assignType(cpy.New(tree)(tpt1), tpt1) // todo in a later phase: checkInstantiatable(cls, tpt1.pos) } @@ -1366,9 +1366,13 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case poly: PolyType => if (pt.isInstanceOf[PolyProto]) tree else { - val (_, tvars) = constrained(poly, tree) + var typeArgs = tree match { + case Select(New(tpt), nme.CONSTRUCTOR) => tpt.tpe.dealias.argTypesLo + case _ => Nil + } + if (typeArgs.isEmpty) typeArgs = constrained(poly, tree)._2 convertNewArray( - adaptInterpolated(tree.appliedToTypes(tvars), pt, original)) + adaptInterpolated(tree.appliedToTypes(typeArgs), pt, original)) } case wtp => pt match { |