aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-28 16:04:41 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-30 17:22:14 +0100
commitd923d70e2ec381b22d7ce44d5bd58d6d45dab6bc (patch)
tree137428b537cebb2b74bb31a5bc97e472a629ea58 /src/dotty/tools/dotc/typer/Typer.scala
parentf60f81fd7b6ed5f6fb692069ebbc46f2b8098894 (diff)
downloaddotty-d923d70e2ec381b22d7ce44d5bd58d6d45dab6bc.tar.gz
dotty-d923d70e2ec381b22d7ce44d5bd58d6d45dab6bc.tar.bz2
dotty-d923d70e2ec381b22d7ce44d5bd58d6d45dab6bc.zip
Make typing of Try nodes idempotent
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala10
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 e7b6f45d4..355b9f263 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -21,6 +21,7 @@ import Flags._
import Decorators._
import ErrorReporting._
import EtaExpansion.etaExpand
+import dotty.tools.dotc.transform.Erasure.Boxing
import util.Positions._
import util.common._
import util.SourcePosition
@@ -344,6 +345,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
assignType(cpy.Typed(tree)(expr1, tpt1), tpt1)
}
tree.expr match {
+ case ExceptionHandlerSel if (tree.tpt.tpe == defn.ThrowableType) =>
+ tree withType defn.ThrowableType
case id: untpd.Ident if (ctx.mode is Mode.Pattern) && isVarPattern(id) =>
if (id.name == nme.WILDCARD) regularTyped(isWildcard = true)
else {
@@ -667,8 +670,13 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
case h: untpd.Match if ((h.selector eq EmptyTree) // comes from parser
|| (h.selector eq ExceptionHandlerSel)) => // during retyping
val cases1 = typedCases(h.cases, defn.ThrowableType, pt)
- assignType(untpd.Match(ExceptionHandlerSel, cases1), cases1)
+ assignType(untpd.Match(Typed(ExceptionHandlerSel, TypeTree(defn.ThrowableType)), cases1), cases1)
+ case Typed(handler, tpe) if ctx.phaseId > ctx.patmatPhase.id => // we are retyping an expanded pattern
+ typed(tree.handler, pt)
+ case Apply(bx, List(Typed(handler, tpe))) if ctx.erasedTypes && Boxing.isBox(bx.symbol) =>
+ typed(tree.handler, pt)
case _ => typed(tree.handler, defn.FunctionType(defn.ThrowableType :: Nil, pt))
+
}
val finalizer1 = typed(tree.finalizer, defn.UnitType)
assignType(cpy.Try(tree)(expr1, handler1, finalizer1), expr1, handler1)