diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 13 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index fa410a2afd..b1ea837cf6 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -235,6 +235,7 @@ trait Definitions extends reflect.generic.StandardDefinitions { lazy val TraversableClass = getClass("scala.collection.Traversable") lazy val ListModule = getModule("scala.collection.immutable.List") + def List_apply = getMember(ListModule, nme.apply) lazy val NilModule = getModule("scala.collection.immutable.Nil") lazy val SeqModule = getModule("scala.collection.Seq") diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5523aba07e..73bf39bfe3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2466,11 +2466,14 @@ trait Typers { self: Analyzer => } } - if (fun.hasSymbol && fun.symbol.name == nme.apply && - fun.symbol.owner == ListClass && args.isEmpty && !onlyPresentation) - atPos(tree.pos) { gen.mkNil setType restpe } + /** This is translating uses of List() into Nil. This is less + * than ideal from a consistency standpoint, but it shouldn't be + * altered without due caution. + */ + if (fun.symbol == List_apply && args.isEmpty && !onlyPresentation) + atPos(tree.pos)(gen.mkNil setType restpe) else - constfold(treeCopy.Apply(tree, fun, args1).setType(ifPatternSkipFormals(restpe))) + constfold(treeCopy.Apply(tree, fun, args1) setType ifPatternSkipFormals(restpe)) } else if (needsInstantiation(tparams, formals, args)) { //println("needs inst "+fun+" "+tparams+"/"+(tparams map (_.info))) @@ -2488,10 +2491,8 @@ trait Typers { self: Analyzer => if (isByNameParamType(remainingParams.head)) POLYmode else POLYmode | BYVALmode if (remainingParams.tail.nonEmpty) remainingParams = remainingParams.tail - // println("typedArgToPoly(arg, formal): "+(arg, formal)) val arg1 = typedArg(arg, argMode(fun, mode), newmode, lenientPt) val argtparams = context.extractUndetparams() - // println("typedArgToPoly(arg1, argtparams): "+(arg1, argtparams)) if (!argtparams.isEmpty) { val strictPt = formal.instantiateTypeParams(tparams, strictTargs) inferArgumentInstance(arg1, argtparams, strictPt, lenientPt) |