aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-28 16:06:43 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-30 17:22:14 +0100
commit6dcd16ab2040a5a337e78bc77e40228dc9944662 (patch)
tree33c49a572d34a5c6ce41a882b075bb16ae75222c /src
parentd923d70e2ec381b22d7ce44d5bd58d6d45dab6bc (diff)
downloaddotty-6dcd16ab2040a5a337e78bc77e40228dc9944662.tar.gz
dotty-6dcd16ab2040a5a337e78bc77e40228dc9944662.tar.bz2
dotty-6dcd16ab2040a5a337e78bc77e40228dc9944662.zip
Rewrite assignType for Try
After erasure was always wrong(didn't include the type of handler). Now it's able to use both Closures and desugared Math nodes.
Diffstat (limited to 'src')
-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) =