aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-02 18:40:08 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-02 18:40:08 +0100
commitf0d34873c27cfbf7dab3909b9855dfeae4e8506e (patch)
tree21e59f593edce4aab9d24b17c63acff53bd85367 /src/dotty/tools/dotc/typer/Typer.scala
parent20c0a6a92dc2d618fa557bb19d78d8595ca527e6 (diff)
downloaddotty-f0d34873c27cfbf7dab3909b9855dfeae4e8506e.tar.gz
dotty-f0d34873c27cfbf7dab3909b9855dfeae4e8506e.tar.bz2
dotty-f0d34873c27cfbf7dab3909b9855dfeae4e8506e.zip
Adding checks for implicit definitions
1) Result type may not be empty 2) Parameters of implicit conversions may not be singletons Reason for 2) is that we can do a much better caching for eligible implicits if we can widen singleton arguments in ViewProto. This leads to consicderable speedups in implicit search which seem to be hard to get without the restriction.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index aad03c47c..58522ddb3 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -862,6 +862,7 @@ class Typer extends Namer with Applications with Implicits {
val ValDef(mods, name, tpt, rhs) = vdef
val mods1 = typedModifiers(mods)
val tpt1 = typedType(tpt)
+ if (sym is Implicit) checkImplicitTptNonEmpty(vdef)
val rhs1 = rhs match {
case Ident(nme.WILDCARD) => rhs withType tpt1.tpe
case _ => typedExpr(rhs, tpt1.tpe)
@@ -875,6 +876,10 @@ class Typer extends Namer with Applications with Implicits {
val mods1 = typedModifiers(mods)
val tparams1 = tparams mapconserve (typed(_).asInstanceOf[TypeDef])
val vparamss1 = vparamss nestedMapconserve (typed(_).asInstanceOf[ValDef])
+ if (sym is Implicit) {
+ checkImplicitTptNonEmpty(ddef)
+ checkImplicitParamsNotSingletons(vparamss1)
+ }
val tpt1 = typedType(tpt)
val rhs1 = typedExpr(rhs, tpt1.tpe)
cpy.DefDef(ddef, mods1, name, tparams1, vparamss1, tpt1, rhs1).withType(sym.termRefWithSig)