From 1792c9e9bcff1feba7b50a24a46e1e20d8a39d9b Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 12 Jul 2016 04:51:53 +0100 Subject: ExtractAPI: Add support for RecType --- src/dotty/tools/dotc/sbt/ExtractAPI.scala | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/sbt') diff --git a/src/dotty/tools/dotc/sbt/ExtractAPI.scala b/src/dotty/tools/dotc/sbt/ExtractAPI.scala index caba96afa..437e36bb9 100644 --- a/src/dotty/tools/dotc/sbt/ExtractAPI.scala +++ b/src/dotty/tools/dotc/sbt/ExtractAPI.scala @@ -387,6 +387,13 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder Array() } new api.Structure(strict2lzy(Array(parent)), strict2lzy(decl), strict2lzy(Array())) + case tp: RecType => + apiType(tp.parent) + case RecThis(recType) => + // `tp` must be present inside `recType`, so calling `apiType` on + // `recType` would lead to an infinite recursion, we avoid this by + // computing the representation of `recType` lazily. + apiLazy(recType) case tp: AndOrType => val parents = List(apiType(tp.tp1), apiType(tp.tp2)) @@ -408,8 +415,6 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder apiType(tpe) case tp: ThisType => apiThis(tp.cls) - case RecThis(binder) => - apiThis(binder.typeSymbol) // !!! this is almost certainly wrong: binder does not always have a typeSymbol !!! case tp: ParamType => // TODO: Distinguishing parameters based on their names alone is not enough, // the binder is also needed (at least for type lambdas). @@ -434,6 +439,13 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder Constants.emptyType } + def apiLazy(tp: => Type): api.Type = { + // TODO: The sbt api needs a convenient way to make a lazy type. + // For now, we repurpose Structure for this. + val apiTp = lzy(Array(apiType(tp))) + new api.Structure(apiTp, strict2lzy(Array()), strict2lzy(Array())) + } + def apiThis(sym: Symbol): api.Singleton = { val pathComponents = sym.ownersIterator.takeWhile(!_.isEffectiveRoot) .map(s => new api.Id(s.name.toString)) -- cgit v1.2.3