File tree 1 file changed +5
-2
lines changed
src/dotty/tools/dotc/typer
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -300,8 +300,11 @@ trait TypeAssigner {
300
300
tree.withType(defn.NothingType )
301
301
302
302
def assignType (tree : untpd.Try , expr : Tree , handler : Tree )(implicit ctx : Context ) = {
303
- val handlerTypeArgs = handler.tpe.baseArgTypesHi(defn.FunctionClass (1 ))
304
- tree.withType(if (handlerTypeArgs.nonEmpty) expr.tpe | handlerTypeArgs(1 ) else expr.tpe)
303
+ if (handler.isEmpty) tree.withType(expr.tpe)
304
+ else if (handler.tpe.derivesFrom(defn.FunctionClass (1 ))) {
305
+ val handlerTypeArgs = handler.tpe.baseArgTypesHi(defn.FunctionClass (1 ))
306
+ tree.withType(if (handlerTypeArgs.nonEmpty) expr.tpe | handlerTypeArgs(1 ) else expr.tpe /* | Object, as function returns boxed value ??? */ )
307
+ } else tree.withType(expr.tpe | handler.tpe)
305
308
}
306
309
307
310
def assignType (tree : untpd.Throw )(implicit ctx : Context ) =
You can’t perform that action at this time.
0 commit comments