Skip to content
Browse files

Merge pull request #1237 from dragos/backport/better-askLinkPos

Added more variants to achieve getLinkPos
  • Loading branch information...
2 parents 1bd3b3d + dc1e21e commit 0054b6c4677387de712b2612c00bd261f5df0b2d @jsuereth jsuereth committed Sep 4, 2012
Showing with 18 additions and 5 deletions.
  1. +18 −5 src/compiler/scala/tools/nsc/interactive/Global.scala
View
23 src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -747,13 +747,23 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "")
val originalTypeParams = sym.owner.typeParams
parseAndEnter(unit)
val pre = adaptToNewRunMap(ThisType(sym.owner))
- val newsym = pre.typeSymbol.info.decl(sym.name) filter { alt =>
+ val rawsym = pre.typeSymbol.info.decl(sym.name)
+ val newsym = rawsym filter { alt =>
sym.isType || {
try {
val tp1 = pre.memberType(alt) onTypeError NoType
val tp2 = adaptToNewRunMap(sym.tpe) substSym (originalTypeParams, sym.owner.typeParams)
- matchesType(tp1, tp2, false)
- } catch {
+ matchesType(tp1, tp2, false) || {
+ debugLog("getLinkPos matchesType(" + tp1 + ", " + tp2 + ") failed")
+ val tp3 = adaptToNewRunMap(sym.tpe) substSym (originalTypeParams, alt.owner.typeParams)
+ matchesType(tp1, tp3, false) || {
+ debugLog("getLinkPos fallback matchesType(" + tp1 + ", " + tp3 + ") failed")
+ false
+ }
+ }
+ }
+ catch {
+ case ex: ControlThrowable => throw ex
case ex: Throwable =>
println("error in hyperlinking: " + ex)
ex.printStackTrace()
@@ -762,8 +772,11 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "")
}
}
if (newsym == NoSymbol) {
- debugLog("link not found " + sym + " " + source + " " + pre)
- NoPosition
+ if (rawsym.exists && !rawsym.isOverloaded) rawsym.pos
+ else {
+ debugLog("link not found " + sym + " " + source + " " + pre)
+ NoPosition
+ }
} else if (newsym.isOverloaded) {
settings.uniqid.value = true
debugLog("link ambiguous " + sym + " " + source + " " + pre + " " + newsym.alternatives)

0 comments on commit 0054b6c

Please sign in to comment.
Something went wrong with that request. Please try again.