summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-08-18 08:18:10 +0000
committerMartin Odersky <odersky@gmail.com>2008-08-18 08:18:10 +0000
commitc19ea510a36c3daf265415a84a8a45a5e0a2d6a5 (patch)
tree26f2df74f1579e75c0688f22a6591c2e311ee540
parentce47426183a3977cfa23fabc18eca52ee49511f7 (diff)
downloadscala-c19ea510a36c3daf265415a84a8a45a5e0a2d6a5.tar.gz
scala-c19ea510a36c3daf265415a84a8a45a5e0a2d6a5.tar.bz2
scala-c19ea510a36c3daf265415a84a8a45a5e0a2d6a5.zip
Reverted change to implicits to see whether plu...
Reverted change to implicits to see whether plugin build passes
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 79621e00fe..4d57d8bc33 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3633,11 +3633,21 @@ trait Typers { self: Analyzer =>
(info1 != NoImplicitInfo) &&
isStrictlyMoreSpecific(info1.tpe, info2.tpe)
val shadowed = new HashSet[Name](8)
- def hasExplicitResultType(tree: Tree) = tree match {
- case ValDef(_, _, tpt, _) => !tpt.isEmpty
- case DefDef(_, _, _, _, tpt, _) => !tpt.isEmpty
- case _ => false
+ def hasExplicitResultType(sym: Symbol) = {
+ def hasExplicitRT(tree: Tree) = tree match {
+ case ValDef(_, _, tpt, _) => !tpt.isEmpty
+ case DefDef(_, _, _, _, tpt, _) => !tpt.isEmpty
+ case _ => false
+ }
+ sym.rawInfo match {
+ case tc: TypeCompleter => hasExplicitRT(tc.tree)
+ case PolyType(_, tc: TypeCompleter) => hasExplicitRT(tc.tree)
+ case _ => true
+ }
}
+ def comesBefore(sym: Symbol, owner: Symbol) =
+ sym.pos.offset.getOrElse(0) < owner.pos.offset.getOrElse(Integer.MAX_VALUE) &&
+ !(owner.ownerChain contains sym)
/** Should implicit definition symbol `sym' be considered for applicability testing?
* This is the case if one of the following holds:
* - the symbol's type is initialized
@@ -3652,19 +3662,12 @@ trait Typers { self: Analyzer =>
def isValid(sym: Symbol) = {
sym.isInitialized ||
sym.sourceFile == null ||
- (sym.sourceFile ne context.unit.source.file) || {
- sym.rawInfo match {
- case tc: TypeCompleter => hasExplicitResultType(tc.tree)
- case PolyType(_, tc: TypeCompleter) => hasExplicitResultType(tc.tree)
- case _ => true
- }
- } || {
- sym.pos.offset.getOrElse(0) < context.owner.pos.offset.getOrElse(Integer.MAX_VALUE) &&
- !(context.owner.ownerChain contains sym)
- }
+ (sym.sourceFile ne context.unit.source.file) ||
+ hasExplicitResultType(sym) ||
+ comesBefore(sym, context.owner)
}
def isApplicable(info: ImplicitInfo): Boolean =
- isValid(info.sym) &&
+ (true /* for now */ || isValid(info.sym)) &&
!containsError(info.tpe) &&
!(isLocal && shadowed.contains(info.name)) &&
(!isView || info.sym != Predef_identity) &&
@@ -3684,9 +3687,9 @@ trait Typers { self: Analyzer =>
for (alt <- applicable)
if (alt.sym.owner != best.sym.owner && isSubClassOrObject(alt.sym.owner, best.sym.owner)) {
ambiguousImplicitError(best, alt,
- "most specific definition is:",
- "yet alternative definition ",
- "is defined in a subclass.\n Both definitions ")
+ "most specific definition is:",
+ "yet alternative definition ",
+ "is defined in a subclass.\n Both definitions ")
}
tc.typedImplicit(pos, best, pt0, pt, isLocal)
}