Skip to content

Commit 1792c9e

Browse files
committed
ExtractAPI: Add support for RecType
1 parent a6a142e commit 1792c9e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,13 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
387387
Array()
388388
}
389389
new api.Structure(strict2lzy(Array(parent)), strict2lzy(decl), strict2lzy(Array()))
390+
case tp: RecType =>
391+
apiType(tp.parent)
392+
case RecThis(recType) =>
393+
// `tp` must be present inside `recType`, so calling `apiType` on
394+
// `recType` would lead to an infinite recursion, we avoid this by
395+
// computing the representation of `recType` lazily.
396+
apiLazy(recType)
390397
case tp: AndOrType =>
391398
val parents = List(apiType(tp.tp1), apiType(tp.tp2))
392399

@@ -408,8 +415,6 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
408415
apiType(tpe)
409416
case tp: ThisType =>
410417
apiThis(tp.cls)
411-
case RecThis(binder) =>
412-
apiThis(binder.typeSymbol) // !!! this is almost certainly wrong: binder does not always have a typeSymbol !!!
413418
case tp: ParamType =>
414419
// TODO: Distinguishing parameters based on their names alone is not enough,
415420
// the binder is also needed (at least for type lambdas).
@@ -434,6 +439,13 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
434439
Constants.emptyType
435440
}
436441

442+
def apiLazy(tp: => Type): api.Type = {
443+
// TODO: The sbt api needs a convenient way to make a lazy type.
444+
// For now, we repurpose Structure for this.
445+
val apiTp = lzy(Array(apiType(tp)))
446+
new api.Structure(apiTp, strict2lzy(Array()), strict2lzy(Array()))
447+
}
448+
437449
def apiThis(sym: Symbol): api.Singleton = {
438450
val pathComponents = sym.ownersIterator.takeWhile(!_.isEffectiveRoot)
439451
.map(s => new api.Id(s.name.toString))

0 commit comments

Comments
 (0)