diff options
author | Martin Odersky <odersky@gmail.com> | 2013-08-10 12:32:04 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-08-10 12:32:04 +0200 |
commit | 4b32ec471bafe988b64563aaabf2d273220a8644 (patch) | |
tree | f9a1530385e8fc9e0d1ded6b1c755f140fd3b64e /src/dotty/tools/dotc/typer/Applications.scala | |
parent | d318cafbb92518a39c84539c0387c2c93815bb7a (diff) | |
download | dotty-4b32ec471bafe988b64563aaabf2d273220a8644.tar.gz dotty-4b32ec471bafe988b64563aaabf2d273220a8644.tar.bz2 dotty-4b32ec471bafe988b64563aaabf2d273220a8644.zip |
Added typing of Alternatives.
Also changed some maps to mapconserves to avoid unnecessary tree copying.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 242acc43b..334e21ccb 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -467,7 +467,7 @@ trait Applications extends Compatibility { self: Typer => } if (sameSeq(typedArgs, args)) // trick to cut down on tree copying typedArgs = args.asInstanceOf[List[Tree]] - methodType.instantiate(typedArgs map (_.tpe)) + methodType.instantiate(typedArgs.tpes) } val app1 = cpy.Apply(app, normalizedFun, typedArgs).withType(ownType) if (liftedDefs != null && liftedDefs.nonEmpty) Block(liftedDefs.toList, app1) @@ -497,7 +497,7 @@ trait Applications extends Compatibility { self: Typer => def typedApply(tree: untpd.Apply, pt: Type)(implicit ctx: Context): Tree = { if (ctx.mode is Mode.Pattern) - typedUnApply(tree.fun, tree.args, tree, pt) + typedUnApply(tree, pt) else { def realApply(implicit ctx: Context) = { @@ -544,11 +544,11 @@ trait Applications extends Compatibility { self: Typer => def typedTypeApply(tree: untpd.TypeApply, pt: Type)(implicit ctx: Context): Tree = { val typedFn = typedExpr(tree.fun, PolyProtoType(tree.args.length, pt)) - val typedArgs = tree.args map (typedType(_)) + val typedArgs = tree.args mapconserve (typedType(_)) val ownType = typedFn.tpe.widen match { case pt: PolyType => checkBounds(typedArgs, pt, tree.pos) - pt.resultType.substParams(pt, typedArgs map (_.tpe)) + pt.resultType.substParams(pt, typedArgs.tpes) case _ => ctx.error(s"${err.exprStr(typedFn)} does not take type parameters", tree.pos) ErrorType @@ -556,7 +556,8 @@ trait Applications extends Compatibility { self: Typer => cpy.TypeApply(tree, typedFn, typedArgs).withType(ownType) } - def typedUnApply(qual: untpd.Tree, args: List[untpd.Tree], tree: untpd.Apply, pt: Type)(implicit ctx: Context): Tree = { + def typedUnApply(tree: untpd.Apply, pt: Type)(implicit ctx: Context): Tree = { + val Apply(qual, args) = tree def unapplyArgs(unapplyResult: Type)(implicit ctx: Context): List[Type] = { def recur(tp: Type): List[Type] = { @@ -646,7 +647,7 @@ trait Applications extends Compatibility { self: Typer => else Typed(result, TypeTree(ownType)) case tp => val unapplyErr = if (tp.isError) unapply else notAnExtractor(unapply) - val typedArgsErr = args map (typed(_, defn.AnyType)) + val typedArgsErr = args mapconserve (typed(_, defn.AnyType)) cpy.UnApply(tree, unapplyErr, typedArgsErr) withType ErrorType } } |