aboutsummaryrefslogtreecommitdiff
path: root/doc-tool
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-12-19 11:23:55 +0100
committerFelix Mulder <felix.mulder@gmail.com>2016-12-19 11:23:55 +0100
commit6dd758eb603518272c4b8d58816d753db718d952 (patch)
treed34f95159d63095a4823eeb55397a69c5c10e368 /doc-tool
parent59f783a981842ff8aa6299b29083cfaaece82caa (diff)
downloaddotty-6dd758eb603518272c4b8d58816d753db718d952.tar.gz
dotty-6dd758eb603518272c4b8d58816d753db718d952.tar.bz2
dotty-6dd758eb603518272c4b8d58816d753db718d952.zip
Fix #1794: handle TermRef result types in dottydoc
Diffstat (limited to 'doc-tool')
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala52
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/model/factories.scala15
2 files changed, 42 insertions, 25 deletions
diff --git a/doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala b/doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala
index 806d9d0ae..43b679c71 100644
--- a/doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala
@@ -8,6 +8,7 @@ import dotc.CompilationUnit
import dotc.config.Printers.dottydoc
import dotc.core.Contexts.Context
import dotc.core.Comments.ContextDocstrings
+import dotc.core.Types.NoType
import dotc.core.Phases.Phase
import dotc.core.Symbols.{ Symbol, NoSymbol }
@@ -44,32 +45,35 @@ class DocASTPhase extends Phase {
}
def membersFromSymbol(sym: Symbol): List[Entity] = {
- val defs = sym.info.bounds.hi.membersBasedOnFlags(Flags.Method, Flags.Synthetic | Flags.Private)
- .filterNot(_.symbol.owner.name.show == "Any")
- .map { meth =>
- DefImpl(
- meth.symbol,
- meth.symbol.name.show,
- Nil,
- path(meth.symbol),
- returnType(meth.info),
- typeParams(meth.symbol),
- paramLists(meth.info),
- implicitlyAddedFrom = Some(returnType(meth.symbol.owner.info))
+ if (sym.info ne NoType) {
+ val defs = sym.info.bounds.hi.membersBasedOnFlags(Flags.Method, Flags.Synthetic | Flags.Private)
+ .filterNot(_.symbol.owner.name.show == "Any")
+ .map { meth =>
+ DefImpl(
+ meth.symbol,
+ meth.symbol.name.show,
+ Nil,
+ path(meth.symbol),
+ returnType(meth.info),
+ typeParams(meth.symbol),
+ paramLists(meth.info),
+ implicitlyAddedFrom = Some(returnType(meth.symbol.owner.info))
+ )
+ }.toList
+
+ val vals = sym.info.fields.filterNot(_.symbol.is(Flags.Private | Flags.Synthetic)).map { value =>
+ ValImpl(
+ value.symbol,
+ value.symbol.name.show,
+ Nil, path(value.symbol),
+ returnType(value.info),
+ implicitlyAddedFrom = Some(returnType(value.symbol.owner.info))
)
- }.toList
-
- val vals = sym.info.fields.filterNot(_.symbol.is(Flags.Private | Flags.Synthetic)).map { value =>
- ValImpl(
- value.symbol,
- value.symbol.name.show,
- Nil, path(value.symbol),
- returnType(value.info),
- implicitlyAddedFrom = Some(returnType(value.symbol.owner.info))
- )
- }
+ }
- defs ++ vals
+ defs ++ vals
+ }
+ else Nil
}
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/factories.scala b/doc-tool/src/dotty/tools/dottydoc/model/factories.scala
index f95474ef1..433431f1c 100644
--- a/doc-tool/src/dotty/tools/dottydoc/model/factories.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/model/factories.scala
@@ -9,6 +9,7 @@ import dotc.core.TypeApplications._
import dotc.core.Contexts.Context
import dotc.core.Symbols.{ Symbol, ClassSymbol }
import dotty.tools.dotc.core.SymDenotations._
+import dotty.tools.dotc.config.Printers.dottydoc
import dotty.tools.dotc.core.Names.TypeName
import dotc.ast.Trees._
@@ -105,6 +106,17 @@ object factories {
else paramName
typeRef(name)
+ case tr: TermRef =>
+ /** A `TermRef` appears in the return type in e.g:
+ * ```
+ * def id[T](t: T): t.type = t
+ * ```
+ */
+ val name = tr.show
+ if (!name.endsWith(".type"))
+ ctx.warning(s"unhandled return type found: $tr")
+
+ typeRef(name, params = params)
}
expandTpe(t)
@@ -154,7 +166,8 @@ object factories {
case annot: AnnotatedType => paramLists(annot.tpe)
case (_: PolyParam | _: RefinedType | _: TypeRef | _: ThisType |
- _: ExprType | _: OrType | _: AndType | _: HKApply) => Nil // return types should not be in the paramlist
+ _: ExprType | _: OrType | _: AndType | _: HKApply | _: TermRef) =>
+ Nil // return types should not be in the paramlist
}
def superTypes(t: Tree)(implicit ctx: Context): List[MaterializableLink] = t.symbol.denot match {