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 @@ -314,8 +314,11 @@ trait TypeAssigner {
314
314
tree.withType(defn.NothingType )
315
315
316
316
def assignType (tree : untpd.Try , expr : Tree , handler : Tree )(implicit ctx : Context ) = {
317
- val handlerTypeArgs = handler.tpe.baseArgTypesHi(defn.FunctionClass (1 ))
318
- tree.withType(if (handlerTypeArgs.nonEmpty) expr.tpe | handlerTypeArgs(1 ) else expr.tpe)
317
+ if (handler.isEmpty) tree.withType(expr.tpe)
318
+ else if (handler.tpe.derivesFrom(defn.FunctionClass (1 ))) {
319
+ val handlerTypeArgs = handler.tpe.baseArgTypesHi(defn.FunctionClass (1 ))
320
+ tree.withType(if (handlerTypeArgs.nonEmpty) expr.tpe | handlerTypeArgs(1 ) else expr.tpe /* | Object, as function returns boxed value ??? */ )
321
+ } else tree.withType(expr.tpe | handler.tpe)
319
322
}
320
323
321
324
def assignType (tree : untpd.Throw )(implicit ctx : Context ) =
You can’t perform that action at this time.
0 commit comments