aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-02-28 13:56:22 +0100
committerMartin Odersky <odersky@gmail.com>2015-02-28 14:01:11 +0100
commit83d435640e0a2645256bc588306fdeef1d5799a2 (patch)
tree389512ec23093072ee57c4559a3260bfe3816f49 /src/dotty
parent4e9987740f206c2376957d08d626f7c1ed087688 (diff)
downloaddotty-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')
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala12
2 files changed, 9 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index b7028430b..238c43854 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -1408,12 +1408,7 @@ object Parsers {
}
/** Wrap annotation or constructor in New(...).<init> */
- def wrapNew(tpt: Tree) = tpt match {
- case AppliedTypeTree(tpt1, targs) =>
- TypeApply(Select(New(tpt1), nme.CONSTRUCTOR), targs)
- case _ =>
- Select(New(tpt), nme.CONSTRUCTOR)
- }
+ def wrapNew(tpt: Tree) = Select(New(tpt), nme.CONSTRUCTOR)
/** Adjust start of annotation or constructor to position of preceding @ or new */
def adjustStart(start: Offset)(tree: Tree): Tree = {
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 {