diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/DocComments.scala')
-rwxr-xr-x | src/compiler/scala/tools/nsc/ast/DocComments.scala | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index 3144d8140d..febb4b221d 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -58,13 +58,17 @@ trait DocComments { self: SymbolTable => * of the same string are done, which is * interpreted as a recursive variable definition. */ - def expandedDocComment(sym: Symbol, site: Symbol): String = - expandVariables(cookedDocComment(sym), sym, site) + def expandedDocComment(sym: Symbol, site: Symbol): String = { + // when parsing a top level class or module, use the (module-)class itself to look up variable definitions + val site1 = if ((sym.isModule || sym.isClass) && (site hasFlag Flags.PACKAGE)) sym + else site + expandVariables(cookedDocComment(sym), sym, site1) + } /** The cooked doc comment of symbol `sym` after variable expansion, or "" if missing. * @param sym The symbol for which doc comment is returned (site is always the containing class) */ - def expandedDocComment(sym: Symbol): String = expandedDocComment(sym, sym) + def expandedDocComment(sym: Symbol): String = expandedDocComment(sym, sym.enclClass) /** The list of use cases of doc comment of symbol `sym` seen as a member of class * `site`. Each use case consists of a synthetic symbol (which is entered nowhere else), @@ -203,11 +207,18 @@ trait DocComments { self: SymbolTable => def lookupVariable(vble: String, site: Symbol): Option[String] = if (site == NoSymbol) None - else - mapFind(site.info.baseClasses)(defs(_).get(vble)) match { + else { + def lookInBaseClasses = mapFind(site.info.baseClasses)(defs(_).get(vble)) match { case None => lookupVariable(vble, site.owner) case someStr => someStr } + if (site.isModule) + defs(site).get(vble) match { + case Some(str) => return Some(str) + case None => lookInBaseClasses + } + else lookInBaseClasses + } private var expandCount = 0 private final val expandLimit = 10 |