diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2009-08-21 16:15:58 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2009-08-21 16:15:58 +0000 |
commit | 78b61c43da92f9af2bcd09b61ed08c824f37cd8b (patch) | |
tree | 90002e74ed089a3575ade9e6e14a5a56b48a7b00 /src/compiler/scala/tools/nsc/typechecker/Implicits.scala | |
parent | f73e819a415ecd290c5464206a4ef2a4080075f5 (diff) | |
download | scala-78b61c43da92f9af2bcd09b61ed08c824f37cd8b.tar.gz scala-78b61c43da92f9af2bcd09b61ed08c824f37cd8b.tar.bz2 scala-78b61c43da92f9af2bcd09b61ed08c824f37cd8b.zip |
replaced the implicit `identity` coercion by `c...
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.
because conforms/identity was no longer prevented from being used as
a view (which does not make sense, but preventing it shouldn't be
necessary), removeNames in NamesDefaults suddenly didn't detect all
ambiguities because it relied on tryTypedApply failing fixed by using an
EmptyTree as an ambiguous argument instead of the argument, so failure
is guaranteed
fixed check file for t0590
new starr
fixed the weirdest bug ever: don't know why, but can't change the total
number of calls to newTermName in StdNames (so take away the one for
"identity", give one back, doesn't matter where --> see "utterweirdness"
at the end) the problem manifested itself by not finding Nil. This only
happens during start up (when the scala/package.scala file hasn't been
compiled yet), when Nil is required before List (because that would have
forced Nil to be loaded).
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index dc00955e0b..bce3c4a5ee 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -247,16 +247,17 @@ self: Analyzer => private def typedImplicit(info: ImplicitInfo): SearchResult = context.openImplicits find (dominates(pt, _)) match { case Some(pending) => - //println("Pending implicit "+pending+" dominates "+pt+"/"+undetParams) + // println("Pending implicit "+pending+" dominates "+pt+"/"+undetParams) //@MDEBUG throw DivergentImplicit SearchFailure case None => try { context.openImplicits = pt :: context.openImplicits - //println(" "*context.openImplicits.length+"typed implicit "+info+" for "+pt) + // println(" "*context.openImplicits.length+"typed implicit "+info+" for "+pt) //@MDEBUG 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( @@ -413,16 +414,17 @@ 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)) typedImplicit(info) - else SearchFailure + 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) def appInfos(is: List[ImplicitInfo]): Map[ImplicitInfo, SearchResult] = { var applicable = Map[ImplicitInfo, SearchResult]() |