summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2009-08-21 10:35:24 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2009-08-21 10:35:24 +0000
commit0c7b99fbc83ab247f78fc51e182a3f612ea03124 (patch)
tree90769a68a120d1d2dddf8aca143496268a7ba97d /src/compiler
parent69d4d8c0a34c94e72d69af1039c0a6131b97bb82 (diff)
downloadscala-0c7b99fbc83ab247f78fc51e182a3f612ea03124.tar.gz
scala-0c7b99fbc83ab247f78fc51e182a3f612ea03124.tar.bz2
scala-0c7b99fbc83ab247f78fc51e182a3f612ea03124.zip
Revert several commits related to implicits/predef
This reverts commits ce0ebb316c094814d72cc7dfcc7ac8e7c22f16c2 cd61aed60d71441308967bece13d87384a59d3e8 0becf263fe8f1dc74bc7277be5d2c6ed04047923
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala1
-rw-r--r--src/compiler/scala/tools/nsc/symtab/StdNames.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala16
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala7
5 files changed, 11 insertions, 23 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index a88603cf05..60b30d8a00 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -111,6 +111,7 @@ trait Definitions {
if (!ClassClass.unsafeTypeParams.isEmpty && !phase.erasedTypes)
appliedType(ClassClass.tpe, List(classType))
else ClassClass.tpe
+ def Predef_identity = getMember(PredefModule, nme.identity)
def Predef_error = getMember(PredefModule, nme.error)
lazy val ConsoleModule: Symbol = getModule("scala.Console")
lazy val ScalaRunTimeModule: Symbol = getModule("scala.runtime.ScalaRunTime")
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
index 4c05fe67ad..baeea7273a 100644
--- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala
+++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
@@ -295,6 +295,7 @@ trait StdNames {
val hashCode_ = newTermName("hashCode")
val hasNext = newTermName("hasNext")
val head = newTermName("head")
+ val identity = newTermName("identity")
val invoke_ = newTermName("invoke")
val isInstanceOf_ = newTermName("isInstanceOf")
val isDefinedAt = newTermName("isDefinedAt")
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 0472f4fb21..6a6c3687e0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -247,17 +247,16 @@ self: Analyzer =>
private def typedImplicit(info: ImplicitInfo): SearchResult =
context.openImplicits find (dominates(pt, _)) match {
case Some(pending) =>
- // println("Pending implicit "+pending+" dominates "+pt+"/"+undetParams) //@MDEBUG
+ //println("Pending implicit "+pending+" dominates "+pt+"/"+undetParams)
throw DivergentImplicit
SearchFailure
case None =>
try {
context.openImplicits = pt :: context.openImplicits
- // println(" "*context.openImplicits.length+"typed implicit "+info+" for "+pt) //@MDEBUG
+ //println(" "*context.openImplicits.length+"typed implicit "+info+" for "+pt)
typedImplicit0(info)
} catch {
case DivergentImplicit =>
- // println("DivergentImplicit for pt:"+ pt +", open implicits:"+context.openImplicits) //@MDEBUG
if (context.openImplicits.tail.isEmpty) {
if (!(pt.isErroneous))
context.unit.error(
@@ -414,17 +413,16 @@ self: Analyzer =>
* This is the case if all of the following holds:
* - the info's type is not erroneous,
* - the info is not shadowed by another info with the same name,
+ * - if the symbol is Predef.identity, then we are not looking for a view,
* - the result of typedImplicit is non-empty.
* @return A search result with an attributed tree containing the implicit if succeeded,
* SearchFailure if not.
*/
def tryImplicit(info: ImplicitInfo): SearchResult =
- 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),
- // 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)
+ if (!containsError(info.tpe) &&
+ !(isLocal && shadowed.contains(info.name)) &&
+ (!isView || info.sym != Predef_identity)) typedImplicit(info)
+ else SearchFailure
def appInfos(is: List[ImplicitInfo]): Map[ImplicitInfo, SearchResult] = {
var applicable = Map[ImplicitInfo, SearchResult]()
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 9d485cc730..482c53fac5 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -390,16 +390,9 @@ trait NamesDefaults { self: Analyzer =>
argPos(index) = pos
rhs
case t: Tree =>
- //@M was: errorTree(arg, ...)
- // this throws an exception that's caught in `tryTypedApply` (as it uses `silent`)
- // unfortunately, tryTypedApply recovers from the exception if you use errorTree(arg, ...) and conforms is allowed as a view (see tryImplicit in Implicits)
- // because it tries to produce a new qualifier (if the old one was P, the new one will be conforms.apply(P)), and if that works, it pretends nothing happened
- // so, to make sure tryTypedApply fails, pass EmptyTree instead
- errorTree(EmptyTree, "reference to "+ name +" is ambiguous; it is both, a parameter\n"+
+ errorTree(arg, "reference to "+ name +" is ambiguous; it is both, a parameter\n"+
"name of the method and the name of a variable currently in scope.")
}
- //@M note that we don't get here when an ambiguity was detected (during the computation of res),
- // as errorTree throws an exception
typer.context.undetparams = udp
res
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index b609f1f24b..745d1c8241 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -991,12 +991,7 @@ trait Typers { self: Analyzer =>
if (qual.isTerm &&
((qual.symbol eq null) || !qual.symbol.isTerm || qual.symbol.isValue) &&
phase.id <= currentRun.typerPhase.id && !qtpe.isError && !tp.isError &&
- qtpe.typeSymbol != NullClass && qtpe.typeSymbol != NothingClass && qtpe != WildcardType &&
- context.implicitsEnabled) { // don't try to adapt a top-level type that's the subject of an implicit search
- // this happens because, if isView, typedImplicit tries to apply the "current" implicit value to
- // a value that needs to be coerced, so we check whether the implicit value has an `apply` method
- // (if we allow this, we get divergence, e.g., starting at `conforms` during ant quick.bin)
- // note: implicit arguments are still inferred (this kind of "chaining" is allowed)
+ qtpe.typeSymbol != NullClass && qtpe.typeSymbol != NothingClass && qtpe != WildcardType) {
val coercion = inferView(qual, qtpe, name, tp)
if (coercion != EmptyTree)
typedQualifier(atPos(qual.pos)(Apply(coercion, List(qual))))