aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/sbt
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-07-12 04:51:53 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-07-12 04:51:53 +0100
commit1792c9e9bcff1feba7b50a24a46e1e20d8a39d9b (patch)
tree3399c5d34a6599683ab2624ebb2e377a8834c644 /src/dotty/tools/dotc/sbt
parenta6a142e772b43fb44ba7086ba1005e983059285a (diff)
downloaddotty-1792c9e9bcff1feba7b50a24a46e1e20d8a39d9b.tar.gz
dotty-1792c9e9bcff1feba7b50a24a46e1e20d8a39d9b.tar.bz2
dotty-1792c9e9bcff1feba7b50a24a46e1e20d8a39d9b.zip
ExtractAPI: Add support for RecType
Diffstat (limited to 'src/dotty/tools/dotc/sbt')
-rw-r--r--src/dotty/tools/dotc/sbt/ExtractAPI.scala16
1 files changed, 14 insertions, 2 deletions
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))