Skip to content

Fix #1643: More robust untpd.New #1660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
case TypedSplice(AppliedTypeTree(tycon, targs)) =>
(TypedSplice(tycon), targs map (TypedSplice(_)))
case TypedSplice(tpt1: Tree) =>
val argTypes = tpt1.tpe.argTypes
val argTypes = tpt1.tpe.argTypesLo
val tycon = tpt1.tpe.withoutArgs(argTypes)
def wrap(tpe: Type) = TypeTree(tpe) withPos tpt.pos
(wrap(tycon), argTypes map wrap)
Expand Down
10 changes: 9 additions & 1 deletion src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit

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

@tailrec def loop(implicit ctx: Context): Type = {
Expand Down Expand Up @@ -446,6 +446,14 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
case _ =>
}
checkClassType(tpt1.tpe, tpt1.pos, traitReq = false, stablePrefixReq = true)

tpt1 match {
case AppliedTypeTree(_, targs) =>
for (targ @ TypeBoundsTree(_, _) <- targs)
ctx.error("type argument must be fully defined", targ.pos)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to not introduce new string error messages and to make a new error message class by following Felix's guide instead: #1589

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed in principle, but I think it's best to leave that to others who are already in it. Crafting a good error message takes time. But my goal here is to clear the backlog of fuzzing errors, so I want to move quickly.

case _ =>
}

assignType(cpy.New(tree)(tpt1), tpt1)
// todo in a later phase: checkInstantiatable(cls, tpt1.pos)
}
Expand Down
19 changes: 19 additions & 0 deletions tests/neg/i1643.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
trait T extends Array {
def t1(as: String*): Array[String] = { varargs1(as: _*) } // error
def t2(as: String*): Array[String] = { super.varargs1(as: _*) } // error
}
class C extends Base_1 { // error
def c1(as: String*): Array[String] = { varargs1(as: _*) } // error
def c2(as: String*): Array[String] = { super.varargs1(as: _*) } // error
}
object Test extends App {
val t = new T {} // error
println(t.t1("a", "b").mkString(","))
println(t.t2("a", "b").mkString(","))
val c = new C {}
println(c.c1("a", "b").mkString(","))
println(c.c2("a", "b").mkString(","))

class CC[T]
val x = new CC[_] // error
}