diff options
author | Martin Odersky <odersky@gmail.com> | 2016-11-05 15:45:03 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-11-05 15:45:11 +0100 |
commit | cf351a20fcd9de79eedeca76fad59bad55d5a5ec (patch) | |
tree | 70eb84e7cbd58884094c4d0e23c58bb67a18fc21 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | f532c9acb9aef9a93f52109c320ea5c944de46bc (diff) | |
download | dotty-cf351a20fcd9de79eedeca76fad59bad55d5a5ec.tar.gz dotty-cf351a20fcd9de79eedeca76fad59bad55d5a5ec.tar.bz2 dotty-cf351a20fcd9de79eedeca76fad59bad55d5a5ec.zip |
Disallow wildcard arguments in new
These might lead to bad bounds if unchecked.
Scalac disallows them also, but with a confusing error message
("class type expected" on the class).
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 899b857ae..95f0c5614 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -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 = { @@ -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) + case _ => + } + assignType(cpy.New(tree)(tpt1), tpt1) // todo in a later phase: checkInstantiatable(cls, tpt1.pos) } |