diff options
Diffstat (limited to 'src')
3 files changed, 22 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/model/Entity.scala b/src/compiler/scala/tools/nsc/doc/model/Entity.scala index 6d81b8271e..3b6323525f 100644 --- a/src/compiler/scala/tools/nsc/doc/model/Entity.scala +++ b/src/compiler/scala/tools/nsc/doc/model/Entity.scala @@ -97,7 +97,9 @@ trait Class extends Trait with HigherKinded { } /** A ''documentable'' object. */ -trait Object extends DocTemplateEntity +trait Object extends DocTemplateEntity { + def isNested: Boolean = false +} /** A package that contains at least one ''documentable'' class, trait, * object or package. */ diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index 14f5263313..885da06a09 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -370,6 +370,12 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory members collect { case d: Constructor => d } def primaryConstructor = constructors find { _.isPrimary } } + else if (isNestedObjectLazyVal(bSym)) + new DocTemplateImpl(bSym, minimumInTpl) with Object { + override def isNested = true + override def isObject = true + override def isLazyVal = false + } else throw new Error("'" + bSym + "' that isn't a class, trait or object cannot be built as a documentable template") } @@ -379,9 +385,13 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory def makeMember0(bSym: Symbol): Option[MemberImpl] = { if (bSym.isGetter && bSym.isLazy) - Some(new NonTemplateMemberImpl(bSym, inTpl) with Val { - override def isLazyVal = true - }) + Some( + if (isNestedObjectLazyVal(bSym)) + makeDocTemplate(bSym, inTpl) + else + new NonTemplateMemberImpl(bSym, inTpl) with Val { + override def isLazyVal = true + }) else if (bSym.isGetter && bSym.accessed.isMutable) Some(new NonTemplateMemberImpl(bSym, inTpl) with Val { override def isVar = true @@ -565,12 +575,16 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory ( aSym.owner == NoSymbol || templateShouldDocument(aSym.owner) ) && !isEmptyJavaObject(aSym) } + def isNestedObjectLazyVal(aSym: Symbol): Boolean = { + aSym.isLazy && !aSym.isRootPackage && !aSym.owner.isPackageClass && (aSym.lazyAccessor != NoSymbol) + } + def isEmptyJavaObject(aSym: Symbol): Boolean = { def hasMembers = aSym.info.members.exists(s => localShouldDocument(s) && (!s.isConstructor || s.owner == aSym)) aSym.isModule && aSym.hasFlag(Flags.JAVA) && !hasMembers } def localShouldDocument(aSym: Symbol): Boolean = { - !aSym.isPrivate && (aSym.isProtected || aSym.privateWithin == NoSymbol) && !aSym.isSynthetic + !aSym.isPrivate && (aSym.isProtected || aSym.privateWithin == NoSymbol) && (!aSym.isSynthetic || isNestedObjectLazyVal(aSym)) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 3044e61f2f..dbbc9ed3e5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -52,7 +52,7 @@ abstract class RefChecks extends InfoTransform { override def changesBaseClasses = false def transformInfo(sym: Symbol, tp: Type): Type = { - def isNestedModule = sym.isModule && !sym.isRoot && !sym.owner.isPackageClass + def isNestedModule = sym.isModule && !sym.isRootPackage && !sym.owner.isPackageClass if (sym.isModule && !sym.isStatic) { |