aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/TypeAssigner.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/typer/TypeAssigner.scala')
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 193af8f0e..bb488bdc5 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -313,12 +313,9 @@ trait TypeAssigner {
def assignType(tree: untpd.Return)(implicit ctx: Context) =
tree.withType(defn.NothingType)
- def assignType(tree: untpd.Try, expr: Tree, handler: Tree)(implicit ctx: Context) = {
- if(handler.isEmpty) tree.withType(expr.tpe)
- else if(handler.tpe.derivesFrom(defn.FunctionClass(1))) {
- val handlerTypeArgs = handler.tpe.baseArgTypesHi(defn.FunctionClass(1))
- tree.withType(if (handlerTypeArgs.nonEmpty) expr.tpe | handlerTypeArgs(1) else expr.tpe /*| Object, as function returns boxed value ??? */)
- } else tree.withType(expr.tpe | handler.tpe)
+ def assignType(tree: untpd.Try, expr: Tree, cases: List[CaseDef])(implicit ctx: Context) = {
+ if (cases.isEmpty) tree.withType(expr.tpe)
+ else tree.withType(ctx.typeComparer.lub(expr.tpe :: cases.tpes))
}
def assignType(tree: untpd.Throw)(implicit ctx: Context) =