summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2009-10-21 18:33:45 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2009-10-21 18:33:45 +0000
commit247895b5e023bf6038988f7da485495012e66b9b (patch)
tree53a2658a5aaeabfd389cbf8ccccada67db0e78da /src/compiler/scala/tools/nsc/typechecker/Implicits.scala
parent2ae67db5557f512e2c8e1e4f5fd8205b1e0f324c (diff)
downloadscala-247895b5e023bf6038988f7da485495012e66b9b.tar.gz
scala-247895b5e023bf6038988f7da485495012e66b9b.tar.bz2
scala-247895b5e023bf6038988f7da485495012e66b9b.zip
refactoring of TypeVar to set the stage for tcp...
refactoring of TypeVar to set the stage for tcpoly inference (also touched UndoLog, isHigherKinded logic in TypeRef) added <:< implicit, should bootstrap selection from squashed commit messages: commented out stuff so that this can be used to bootstrap and build a new starr merged/cherry picked refactorings unrelated to #2261 (undoLog, cloneInternal, NoImplicitInfo) made conforms implicit, identity explicit replaced the implicit `identity` coercion by `conforms`, which can be used to encode generalised constraints the introduction of `conforms` revealed a bug in adaptToMember, which was inferring views while already inferring one, which gave rise to diverging implicits. Predef.identity is no longer special as far as the compiler is concerned. cleaned up isHigherKinded logic in TypeRef, and implemented it in TypeVar along with normalize added <:< to Predef: use as evidence for encoding generalized constraints (BTW: extractUndetparams clears undetparams: don't use in debug output -- I learned the hard way...) added todo about ticket 2066 -- branching from master to explicitkinds for fix refactoring: moved bounds tracking logic to TypeVar introduced typeConstructor in Type because we can't use appliedType(tp, List())) to strip a type's type arguments (appliedType is a no-op for empty args) -- don't want to pattern match on type either removed unused overrides in TypeVar (TODO double check) making appliedType more robust since it is now used more liberally -- neg/t0226 should no longer fail now merged in appliedType refactoring and added TypeVar logic to appliedType
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index a83ce8e53b..76e4818a72 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -103,13 +103,10 @@ self: Analyzer =>
override def equals(other: Any) = other match {
case that: ImplicitInfo =>
- if (this eq NoImplicitInfo) that eq this
- else
this.name == that.name &&
this.pre =:= that.pre &&
this.sym == that.sym
- case _ =>
- false
+ case _ => false
}
override def hashCode =
@@ -119,7 +116,12 @@ self: Analyzer =>
}
/** A sentinel indicating no implicit was found */
- val NoImplicitInfo = new ImplicitInfo(null, NoType, NoSymbol)
+ val NoImplicitInfo = new ImplicitInfo(null, NoType, NoSymbol) {
+ // equals used to be implemented in ImplicitInfo with an `if(this eq NoImplicitInfo)`
+ // overriding the equals here seems cleaner and benchmarks show no difference in performance
+ override def equals(other: Any) = other match { case that: AnyRef => that eq this case _ => false }
+ override def hashCode = 1
+ }
/** A constructor for types ?{ name: tp }, used in infer view to member
* searches.
@@ -510,6 +512,7 @@ self: Analyzer =>
if (containsError(info.tpe) ||
(isLocal && shadowed.contains(info.name)) ||
(isView && (info.sym == Predef_identity || info.sym == Predef_conforms)) //@M this condition prevents no-op conversions, which are a problem (besides efficiency),
+ // TODO: remove `info.sym == Predef_identity` once we have a new STARR that only has conforms as an implicit
// one example is removeNames in NamesDefaults, which relies on the type checker failing in case of ambiguity between an assignment/named arg
) SearchFailure
else typedImplicit(info)