aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Checking.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-10-07 12:42:38 +0200
committerMartin Odersky <odersky@gmail.com>2015-10-07 13:41:58 +0200
commit6cca64fa0aa37942812d1c870b99f309dab67352 (patch)
tree5d2e357e72c22ca64a8fad770a8002fc4ff15bcf /src/dotty/tools/dotc/typer/Checking.scala
parenta8c8bdad57941071b85caa54bc57b84d8ca7d526 (diff)
downloaddotty-6cca64fa0aa37942812d1c870b99f309dab67352.tar.gz
dotty-6cca64fa0aa37942812d1c870b99f309dab67352.tar.bz2
dotty-6cca64fa0aa37942812d1c870b99f309dab67352.zip
Check that some types are not higher-kinded.
Invalidates #813. Review by @darkdimius.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Checking.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Checking.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala
index 9092523db..8f4a8b72b 100644
--- a/src/dotty/tools/dotc/typer/Checking.scala
+++ b/src/dotty/tools/dotc/typer/Checking.scala
@@ -16,6 +16,7 @@ import Trees._
import ProtoTypes._
import Constants._
import Scopes._
+import ErrorReporting.errorTree
import annotation.unchecked
import util.Positions._
import util.{Stats, SimpleMap}
@@ -347,6 +348,17 @@ trait Checking {
ctx.error(i"""$called is already implemented by super${caller.superClass},
|its constructor cannot be called again""".stripMargin, call.pos)
}
+
+ /** Check that `tpt` does not define a higher-kinded type */
+ def checkSimpleKinded(tpt: Tree)(implicit ctx: Context): Tree =
+ if (tpt.tpe.isHK && !ctx.compilationUnit.isJava) {
+ // be more lenient with missing type params in Java,
+ // needed to make pos/java-interop/t1196 work.
+ val alias = tpt.tpe.dealias
+ if (alias.isHK) errorTree(tpt, d"missing type parameter for ${tpt.tpe}")
+ else tpt.withType(alias)
+ }
+ else tpt
}
trait NoChecking extends Checking {
@@ -360,4 +372,5 @@ trait NoChecking extends Checking {
override def checkFeasible(tp: Type, pos: Position, where: => String = "")(implicit ctx: Context): Type = tp
override def checkNoDoubleDefs(cls: Symbol)(implicit ctx: Context): Unit = ()
override def checkParentCall(call: Tree, caller: ClassSymbol)(implicit ctx: Context) = ()
+ override def checkSimpleKinded(tpt: Tree)(implicit ctx: Context): Tree = tpt
}