diff options
author | Martin Odersky <odersky@gmail.com> | 2007-02-20 18:03:29 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-02-20 18:03:29 +0000 |
commit | 45bcd02f6ba099277bedbf83ec2bda07435c7797 (patch) | |
tree | 559f799a725f8ec403e5a3db6ced5c695349df2b /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | 5db82b1e48cb2cdb98e5b3826e1439b9c80d17bd (diff) | |
download | scala-45bcd02f6ba099277bedbf83ec2bda07435c7797.tar.gz scala-45bcd02f6ba099277bedbf83ec2bda07435c7797.tar.bz2 scala-45bcd02f6ba099277bedbf83ec2bda07435c7797.zip |
now allows & for by-name params and parameters ...
now allows & for by-name params and parameters methods.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index be1472307a..199dbe9cdb 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2127,29 +2127,39 @@ trait Typers requires Analyzer { copy.New(tree, tpt1).setType(tpt1.tpe) case Typed(expr, Function(List(), EmptyTree)) => - val expr1 = typed1(expr, mode, pt); - if (isFunctionType(pt)) expr1 - else expr1.tpe match { + val expr1 = typed1(expr, mode, pt) + expr1.tpe match { + case TypeRef(_, sym, _) if (sym == ByNameParamClass) => + val expr2 = Function(List(), expr1) + new ChangeOwnerTraverser(context.owner, expr2.symbol).traverse(expr2) + typed1(expr2, mode, pt) + case PolyType(List(), restpe) => + val expr2 = Function(List(), expr1) + new ChangeOwnerTraverser(context.owner, expr2.symbol).traverse(expr2) + typed1(expr2, mode, pt) case PolyType(_, MethodType(formals, _)) => - adapt(expr1, mode, functionType(formals map (t => WildcardType), WildcardType)) + if (isFunctionType(pt)) expr1 + else adapt(expr1, mode, functionType(formals map (t => WildcardType), WildcardType)) case MethodType(formals, _) => - expr1 match { - case Select(qual, name) => - if(forMSIL && pt != WildcardType && pt != ErrorType && isSubType(pt, definitions.DelegateClass.tpe)) { - val scalaCaller = newScalaCaller(pt); - addScalaCallerInfo(scalaCaller, expr1.symbol) - val n: Name = scalaCaller.name - val del = Ident(DelegateClass) setType DelegateClass.tpe - val f = Select(del, n) - //val f1 = TypeApply(f, List(Ident(pt.symbol) setType pt)) - val args: List[Tree] = if(expr1.symbol.isStatic) List(Literal(Constant(null))) - else List(qual) // where the scala-method is located - val rhs = Apply(f, args); - return typed(rhs) - } - case _ => () + if (isFunctionType(pt)) expr1 + else expr1 match { + case Select(qual, name) if (forMSIL && + pt != WildcardType && + pt != ErrorType && + isSubType(pt, definitions.DelegateClass.tpe)) => + val scalaCaller = newScalaCaller(pt); + addScalaCallerInfo(scalaCaller, expr1.symbol) + val n: Name = scalaCaller.name + val del = Ident(DelegateClass) setType DelegateClass.tpe + val f = Select(del, n) + //val f1 = TypeApply(f, List(Ident(pt.symbol) setType pt)) + val args: List[Tree] = if(expr1.symbol.isStatic) List(Literal(Constant(null))) + else List(qual) // where the scala-method is located + val rhs = Apply(f, args); + typed(rhs) + case _ => + adapt(expr1, mode, functionType(formals map (t => WildcardType), WildcardType)) } - adapt(expr1, mode, functionType(formals map (t => WildcardType), WildcardType)) case ErrorType => expr1 case _ => |