aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index cb6fefab1..193af8f0e 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -314,8 +314,11 @@ trait TypeAssigner {
tree.withType(defn.NothingType)
def assignType(tree: untpd.Try, expr: Tree, handler: Tree)(implicit ctx: Context) = {
- val handlerTypeArgs = handler.tpe.baseArgTypesHi(defn.FunctionClass(1))
- tree.withType(if (handlerTypeArgs.nonEmpty) expr.tpe | handlerTypeArgs(1) else expr.tpe)
+ 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.Throw)(implicit ctx: Context) =