aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-05 18:20:25 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-02 16:11:21 +0200
commit60b6c6a3059b23cf0cc1968cc3c7ee3886784721 (patch)
treebb167f7f4ea164aa49c56e35065abceeb710bf2b /src/dotty/tools/dotc
parent5a345e7100450d39edf0034cc5b83bdb9a851cfa (diff)
downloaddotty-60b6c6a3059b23cf0cc1968cc3c7ee3886784721.tar.gz
dotty-60b6c6a3059b23cf0cc1968cc3c7ee3886784721.tar.bz2
dotty-60b6c6a3059b23cf0cc1968cc3c7ee3886784721.zip
Harden ReTyper so that it's fit for inlining
1. Imlement typedUnapply 2. Disable implicit view searches and searches for equality checks - these should have already happened in the first typer run.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--src/dotty/tools/dotc/typer/ReTyper.scala11
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala2
3 files changed, 13 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 55d9fc990..2c9039db1 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -861,7 +861,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
/** A typed unapply hook, can be overridden by re any-typers between frontend
* and pattern matcher.
*/
- def typedUnApply(tree: untpd.UnApply, selType: Type)(implicit ctx: Context) =
+ def typedUnApply(tree: untpd.UnApply, selType: Type)(implicit ctx: Context): UnApply =
throw new UnsupportedOperationException("cannot type check an UnApply node")
/** Is given method reference applicable to type arguments `targs` and argument trees `args`?
diff --git a/src/dotty/tools/dotc/typer/ReTyper.scala b/src/dotty/tools/dotc/typer/ReTyper.scala
index 143d30f9e..1db6b54af 100644
--- a/src/dotty/tools/dotc/typer/ReTyper.scala
+++ b/src/dotty/tools/dotc/typer/ReTyper.scala
@@ -10,6 +10,7 @@ import typer.ProtoTypes._
import ast.{tpd, untpd}
import ast.Trees._
import scala.util.control.NonFatal
+import util.Positions.Position
import config.Printers.typr
/** A version of Typer that keeps all symbols defined and referenced in a
@@ -56,6 +57,13 @@ class ReTyper extends Typer {
untpd.cpy.Bind(tree)(tree.name, body1).withType(tree.typeOpt)
}
+ override def typedUnApply(tree: untpd.UnApply, selType: Type)(implicit ctx: Context): UnApply = {
+ val fun1 = typedExpr(tree.fun, AnyFunctionProto)
+ val implicits1 = tree.implicits.map(typedExpr(_))
+ val patterns1 = tree.patterns.mapconserve(pat => typed(pat, pat.tpe))
+ untpd.cpy.UnApply(tree)(fun1, implicits1, patterns1).withType(tree.tpe)
+ }
+
override def localDummy(cls: ClassSymbol, impl: untpd.Template)(implicit ctx: Context) = impl.symbol
override def retrieveSym(tree: untpd.Tree)(implicit ctx: Context): Symbol = tree.symbol
@@ -93,4 +101,7 @@ class ReTyper extends Typer {
}
override def checkVariance(tree: Tree)(implicit ctx: Context) = ()
+ override def inferView(from: Tree, to: Type)(implicit ctx: Context): Implicits.SearchResult =
+ Implicits.NoImplicitMatches
+ override def checkCanEqual(ltp: Type, rtp: Type, pos: Position)(implicit ctx: Context): Unit = ()
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 8bc156606..22a5095ec 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1570,7 +1570,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
}
- def adapt(tree: Tree, pt: Type, original: untpd.Tree = untpd.EmptyTree)(implicit ctx: Context) = /*>|>*/ track("adapt") /*<|<*/ {
+ def adapt(tree: Tree, pt: Type, original: untpd.Tree = untpd.EmptyTree)(implicit ctx: Context): Tree = /*>|>*/ track("adapt") /*<|<*/ {
/*>|>*/ ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt", typr, show = true) /*<|<*/ {
if (tree.isDef) interpolateUndetVars(tree, tree.symbol)
else if (!tree.tpe.widen.isInstanceOf[MethodOrPoly]) interpolateUndetVars(tree, NoSymbol)