Skip to content

Commit 913f76a

Browse files
authored
Merge pull request #1660 from dotty-staging/fix-#1643
Fix #1643: More robust untpd.New
2 parents a55a260 + cf351a2 commit 913f76a

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
282282
case TypedSplice(AppliedTypeTree(tycon, targs)) =>
283283
(TypedSplice(tycon), targs map (TypedSplice(_)))
284284
case TypedSplice(tpt1: Tree) =>
285-
val argTypes = tpt1.tpe.argTypes
285+
val argTypes = tpt1.tpe.argTypesLo
286286
val tycon = tpt1.tpe.withoutArgs(argTypes)
287287
def wrap(tpe: Type) = TypeTree(tpe) withPos tpt.pos
288288
(wrap(tycon), argTypes map wrap)

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
241241

242242
/** Would import of kind `prec` be not shadowed by a nested higher-precedence definition? */
243243
def isPossibleImport(prec: Int)(implicit ctx: Context) =
244-
!noImports &&
244+
!noImports &&
245245
(prevPrec < prec || prevPrec == prec && (prevCtx.scope eq ctx.scope))
246246

247247
@tailrec def loop(implicit ctx: Context): Type = {
@@ -446,6 +446,14 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
446446
case _ =>
447447
}
448448
checkClassType(tpt1.tpe, tpt1.pos, traitReq = false, stablePrefixReq = true)
449+
450+
tpt1 match {
451+
case AppliedTypeTree(_, targs) =>
452+
for (targ @ TypeBoundsTree(_, _) <- targs)
453+
ctx.error("type argument must be fully defined", targ.pos)
454+
case _ =>
455+
}
456+
449457
assignType(cpy.New(tree)(tpt1), tpt1)
450458
// todo in a later phase: checkInstantiatable(cls, tpt1.pos)
451459
}

tests/neg/i1643.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
trait T extends Array {
2+
def t1(as: String*): Array[String] = { varargs1(as: _*) } // error
3+
def t2(as: String*): Array[String] = { super.varargs1(as: _*) } // error
4+
}
5+
class C extends Base_1 { // error
6+
def c1(as: String*): Array[String] = { varargs1(as: _*) } // error
7+
def c2(as: String*): Array[String] = { super.varargs1(as: _*) } // error
8+
}
9+
object Test extends App {
10+
val t = new T {} // error
11+
println(t.t1("a", "b").mkString(","))
12+
println(t.t2("a", "b").mkString(","))
13+
val c = new C {}
14+
println(c.c1("a", "b").mkString(","))
15+
println(c.c2("a", "b").mkString(","))
16+
17+
class CC[T]
18+
val x = new CC[_] // error
19+
}

0 commit comments

Comments
 (0)