diff options
author | Martin Odersky <odersky@gmail.com> | 2013-02-22 10:26:47 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-02-22 10:26:47 +0100 |
commit | 77c862ed65cf6f6d0593e11e91959c4d08a9187b (patch) | |
tree | 15813d35d196370560c912a68a8b40bd608d0df9 /src/dotty/tools/dotc/core/TypedTrees.scala | |
parent | 008d440d5ff36dc62e1c6a366752cfc49e87461e (diff) | |
download | dotty-77c862ed65cf6f6d0593e11e91959c4d08a9187b.tar.gz dotty-77c862ed65cf6f6d0593e11e91959c4d08a9187b.tar.bz2 dotty-77c862ed65cf6f6d0593e11e91959c4d08a9187b.zip |
Added previously forgotten typed Try trees, modified params of typed Super trees.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypedTrees.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypedTrees.scala | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/TypedTrees.scala b/src/dotty/tools/dotc/core/TypedTrees.scala index f9223b04b..2bdbd66aa 100644 --- a/src/dotty/tools/dotc/core/TypedTrees.scala +++ b/src/dotty/tools/dotc/core/TypedTrees.scala @@ -83,11 +83,14 @@ object TypedTrees { def This(cls: ClassSymbol)(implicit ctx: Context): This = Trees.This(cls.name).withType(cls.thisType).checked - def Super(qual: Tree, mixin: Symbol = NoSymbol)(implicit ctx: Context): Super = { - val cls = qual.tpe.typeSymbol - val (owntype, mix) = - if (mixin.exists) (mixin.typeConstructor, mixin.asType.name) - else (ctx.glb(cls.info.parents), tpnme.EMPTY) + def Super(qual: Tree, mix: TypeName)(implicit ctx: Context): Super = { + val owntype = + if (mix.isEmpty) ctx.glb(qual.tpe.parents) + else { + val mixParents = qual.tpe.parents filter (_.name == mix) + check(mixParents.length == 1) + mixParents.head + } Trees.Super(qual, mix).withType(SuperType(qual.tpe, owntype)).checked } @@ -156,6 +159,9 @@ object TypedTrees { def Return(expr: Tree, from: Ident)(implicit ctx: Context): Return = Trees.Return(expr, from).withType(defn.NothingType).checked + def Try(block: Tree, catches: List[CaseDef], finalizer: Tree)(implicit ctx: Context): Try = + Trees.Try(block, catches, finalizer).withType(ctx.lub(block.tpe :: catches.map(_.tpe))).checked + def Throw(expr: Tree)(implicit ctx: Context): Throw = Trees.Throw(expr).withType(defn.NothingType).checked @@ -391,7 +397,6 @@ object TypedTrees { check(qual.isValue) val cls = qual.tpe.typeSymbol check(cls.isClass) - check(mixin == NoSymbol || (cls.asClass.parents map (_.typeSymbol) contains mixin)) case Apply(fn, args) => def checkArg(arg: tpd.Tree, name: Name, formal: Type): Unit = { arg match { @@ -476,6 +481,9 @@ object TypedTrees { case Return(expr, from) => check(expr.isValue); check(from.isTerm) check(from.tpe.termSymbol.isSourceMethod) + case Try(block, catches, finalizer) => + for (ctch <- catches) + check(ctch.pat.tpe <:< defn.ThrowableType) case Throw(expr) => check(expr.isValue) check(expr.tpe <:< defn.ThrowableType) |