diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2009-08-24 14:03:30 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2009-08-24 14:03:30 +0000 |
commit | 9c8da21394f926eb57df55b4ffa5c316a12155a8 (patch) | |
tree | 6900fc3ed4c1d6c38adbdd2c3af47fe5c220717d /src | |
parent | db8c41b53586961f10c2ba3a48ad14fa622d507f (diff) | |
download | scala-9c8da21394f926eb57df55b4ffa5c316a12155a8.tar.gz scala-9c8da21394f926eb57df55b4ffa5c316a12155a8.tar.bz2 scala-9c8da21394f926eb57df55b4ffa5c316a12155a8.zip |
fixing bootstrapping problem wrt removing ident...
fixing bootstrapping problem wrt removing identity as an implicit
Diffstat (limited to 'src')
4 files changed, 8 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index a51bb31bd4..ffe6cb30ca 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -112,6 +112,7 @@ trait Definitions { appliedType(ClassClass.tpe, List(classType)) else ClassClass.tpe def Predef_error = getMember(PredefModule, nme.error) + def Predef_identity = getMember(PredefModule, nme.identity) def Predef_conforms = getMember(PredefModule, nme.conforms) 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 f3aa58f0ed..5426a76643 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -270,6 +270,7 @@ trait StdNames { val canEqual_ = newTermName("canEqual") val checkInitialized = newTermName("checkInitialized") val classOf = newTermName("classOf") + val identity = newTermName("identity") val conforms = newTermName("conforms") val copy = newTermName("copy") val dottype = newTermName(".type") diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 2bd507ae2d..66fc389807 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -414,6 +414,7 @@ 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, + * - we're not trying to infer a view that amounts to the identity function (specifically, Predef.identity or Predef.conforms) * - the result of typedImplicit is non-empty. * @return A search result with an attributed tree containing the implicit if succeeded, * SearchFailure if not. @@ -421,7 +422,7 @@ self: Analyzer => def tryImplicit(info: ImplicitInfo): SearchResult = if (containsError(info.tpe) || (isLocal && shadowed.contains(info.name)) || - (isView && (info.sym == Predef_conforms)) //@M this condition prevents no-op conversions, which are a problem (besides efficiency), + (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) diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index aa718e1892..7a235bea6c 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -76,9 +76,9 @@ object Predef { val Map = collection.immutable.Map val Set = collection.immutable.Set - // no longer a view: subsumed by `conforms` (which is less likely to give rise to ambiguities) + // will soon stop being a view: subsumed by `conforms` (which is less likely to give rise to ambiguities) // @see `conforms` for the implicit version - def identity[A](x: A): A = x + implicit def identity[A](x: A): A = x // errors and asserts ------------------------------------------------- @@ -256,8 +256,8 @@ object Predef { // reusing `Function2` and `identity` leads to ambiguities (any2stringadd is inferred) // to constrain any abstract type T that's in scope in a method's argument list (not just the method's own type parameters) // simply add an implicit argument of type `T <:< U`, where U is the required upper bound (for lower-bounds, use: `U <: T`) - sealed abstract class <:<[-From, +To] extends (From => To) - implicit def conforms[A]: A <:< A = new (A <:< A) {def apply(x: A) = x} + sealed abstract class <:<[-From, +To] //extends (From => To) + implicit def conforms[A]: A <:< A = new (A <:< A) {def convert(x: A) = x} def currentThread = java.lang.Thread.currentThread() } |