diff options
author | Martin Odersky <odersky@gmail.com> | 2011-01-16 21:31:31 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-01-16 21:31:31 +0000 |
commit | cf820b8907e60214df974a3b2a88ca0a7e877298 (patch) | |
tree | d84b96abaec22ee0258ceb490917ab2dcd4b71ac /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | 3414335ced07828aef1f50e1e61384c026391376 (diff) | |
download | scala-cf820b8907e60214df974a3b2a88ca0a7e877298.tar.gz scala-cf820b8907e60214df974a3b2a88ca0a7e877298.tar.bz2 scala-cf820b8907e60214df974a3b2a88ca0a7e877298.zip |
Dynamic type added. Array creation optimized.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 2b6bf6080c..9085affd62 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3443,21 +3443,21 @@ trait Typers extends Modes { adaptToName(qual, name) } catch { case ex: TypeError => - // this happens if implicits are ambiguous; try again with more context info. - // println("last ditch effort: "+qual+" . "+name) // DEBUG - context.tree match { - case Apply(tree1, args) if tree1 eq tree => // try handling the arguments - // println("typing args: "+args) // DEBUG - silent(_.typedArgs(args, mode)) match { - case args: List[_] => - adaptToArguments(qual, name, args.asInstanceOf[List[Tree]], WildcardType) - case _ => - throw ex - } - case _ => - // println("not in an apply: "+context.tree+"/"+tree) // DEBUG - throw ex - } + // this happens if implicits are ambiguous; try again with more context info. + // println("last ditch effort: "+qual+" . "+name) + context.tree match { + case Apply(tree1, args) if tree1 eq tree => // try handling the arguments + // println("typing args: "+args) + silent(_.typedArgs(args, mode)) match { + case args: List[_] => + adaptToArguments(qual, name, args.asInstanceOf[List[Tree]], WildcardType) + case _ => + throw ex + } + case _ => + // println("not in an apply: "+context.tree+"/"+tree) + throw ex + } } if (qual1 ne qual) return typed(treeCopy.Select(tree, qual1, name), mode, pt) } @@ -3468,6 +3468,22 @@ trait Typers extends Modes { if (tree1 != EmptyTree) return typed1(tree1, mode, pt) } + // try to expand according to Dynamic rules. + + if (qual.tpe.widen.typeSymbol isNonBottomSubClass DynamicClass) { + val op = context.tree match { + case Apply(tree1, args) if tree1 eq tree => + "_invoke_" + + (if (args.length <= Dynamic_OptInvokeMaxArgCount) args.length.toString + else "") + case _ => + "_select_" + } + return typed1( + util.trace("dynatype: ")(Apply(Select(qual, op), List(Literal(Constant(name.toString))))), + mode, pt) + } + if (settings.debug.value) { log( "qual = "+qual+":"+qual.tpe+ |