1
1
package dotty .tools .repl
2
2
3
- import dotty .tools .backend .jvm .GenBCode
4
3
import dotty .tools .dotc .ast .Trees ._
5
4
import dotty .tools .dotc .ast .{tpd , untpd }
6
5
import dotty .tools .dotc .ast .tpd .TreeOps
@@ -15,11 +14,10 @@ import dotty.tools.dotc.core.StdNames._
15
14
import dotty .tools .dotc .core .Symbols ._
16
15
import dotty .tools .dotc .reporting .diagnostic .messages
17
16
import dotty .tools .dotc .transform .PostTyper
18
- import dotty .tools .dotc .typer .{FrontEnd , ImportInfo }
17
+ import dotty .tools .dotc .typer .{FrontEnd , ImportInfo , Typer }
19
18
import dotty .tools .dotc .util .Positions ._
20
19
import dotty .tools .dotc .util .SourceFile
21
20
import dotty .tools .dotc .{CompilationUnit , Compiler , Run }
22
- import dotty .tools .io ._
23
21
import dotty .tools .repl .results ._
24
22
25
23
import scala .collection .mutable
@@ -196,13 +194,18 @@ class ReplCompiler extends Compiler {
196
194
val stat = stats.last.asInstanceOf [tpd.Tree ]
197
195
if (stat.tpe.isError) stat.tpe.show
198
196
else {
199
- val docCtx = ctx.docCtx.get
200
197
val symbols = extractSymbols(stat)
201
- val doc = symbols.collectFirst {
202
- case sym if docCtx.docstrings.contains(sym) =>
203
- docCtx.docstrings(sym).raw
204
- }
205
- doc.getOrElse(s " // No doc for ` ${expr}` " )
198
+ val typer = new Typer ()
199
+ val doc = for {
200
+ sym <- symbols
201
+ owner = sym.owner
202
+ cookingCtx = ctx.withOwner(owner)
203
+ cooked <- typer.cookComment(sym, owner)(cookingCtx)
204
+ body <- cooked.expandedBody
205
+ } yield body
206
+
207
+ if (doc.hasNext) doc.next()
208
+ else s " // No doc for ` $expr` "
206
209
}
207
210
208
211
case _ =>
0 commit comments