diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-23 10:00:50 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-23 12:07:45 -0700 |
commit | d8b96bb8583161e59180527bab0283f783466426 (patch) | |
tree | a12ecf17379a579d5a2f4bda7a16819001eadb77 /src/compiler/scala/tools/nsc/typechecker/Infer.scala | |
parent | b8641a97d669c945a1b9f47b4e8934aa6c98ffd7 (diff) | |
download | scala-d8b96bb8583161e59180527bab0283f783466426.tar.gz scala-d8b96bb8583161e59180527bab0283f783466426.tar.bz2 scala-d8b96bb8583161e59180527bab0283f783466426.zip |
Concision contribution.
We have lots of core classes for which we need not go through
the symbol to get the type:
ObjectClass.tpe -> ObjectTpe
AnyClass.tpe -> AnyTpe
I updated everything to use the concise/direct version,
and eliminated a bunch of noise where places were calling
typeConstructor, erasedTypeRef, and other different-seeming methods
only to always wind up with the same type they would have received
from sym.tpe. There's only one Object type, before or after erasure,
with or without type arguments.
Calls to typeConstructor were especially damaging because (see
previous commit) it had a tendency to cache a different type than
the type one would find via other means. The two types would
compare =:=, but possibly not == and definitely not eq. (I still
don't understand what == is expected to do with types.)
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Infer.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 3abbfbd00c..961ef484d8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -531,7 +531,7 @@ trait Infer extends Checkable { def unapply(m: Result): Some[(List[Symbol], List[Type], List[Type], List[Symbol])] = Some(toLists{ val (ok, nok) = m.map{case (p, a) => (p, a.getOrElse(null))}.partition(_._2 ne null) val (okArgs, okTparams) = ok.unzip - (okArgs, okTparams, m.values.map(_.getOrElse(NothingClass.tpe)), nok.keys) + (okArgs, okTparams, m.values.map(_.getOrElse(NothingTpe)), nok.keys) }) } @@ -581,7 +581,7 @@ trait Infer extends Checkable { /** Return inferred type arguments, given type parameters, formal parameters, * argument types, result type and expected result type. * If this is not possible, throw a `NoInstance` exception. - * Undetermined type arguments are represented by `definitions.NothingClass.tpe`. + * Undetermined type arguments are represented by `definitions.NothingTpe`. * No check that inferred parameters conform to their bounds is made here. * * @param tparams the type parameters of the method @@ -725,7 +725,7 @@ trait Infer extends Checkable { if (pos == -1) { if (positionalAllowed) { // treat assignment as positional argument argPos(index) = index - res = UnitClass.tpe + res = UnitTpe } else // unknown parameter name namesOK = false } else if (argPos.contains(pos)) { // parameter specified twice @@ -773,10 +773,10 @@ trait Infer extends Checkable { * @pre: the argument list is eligible for tuple conversion. */ private def typeAfterTupleConversion(argtpes: List[Type]): Type = ( - if (argtpes.isEmpty) UnitClass.tpe // aka "Tuple0" + if (argtpes.isEmpty) UnitTpe // aka "Tuple0" else tupleType(argtpes map { - case NamedType(name, tp) => UnitClass.tpe // not a named arg - only assignments here - case RepeatedType(tp) => tp // but probably shouldn't be tupling a call containing :_* + case NamedType(name, tp) => UnitTpe // not a named arg - only assignments here + case RepeatedType(tp) => tp // but probably shouldn't be tupling a call containing :_* case tp => tp }) ) |