aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypedTrees.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-02-22 10:26:47 +0100
committerMartin Odersky <odersky@gmail.com>2013-02-22 10:26:47 +0100
commit77c862ed65cf6f6d0593e11e91959c4d08a9187b (patch)
tree15813d35d196370560c912a68a8b40bd608d0df9 /src/dotty/tools/dotc/core/TypedTrees.scala
parent008d440d5ff36dc62e1c6a366752cfc49e87461e (diff)
downloaddotty-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.scala20
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)