aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-07-12 04:48:47 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-07-12 04:48:47 +0100
commita6a142e772b43fb44ba7086ba1005e983059285a (patch)
treea15c1982b4ecb4fad4e39dc014a121f0879156bd /src
parent055726e0cbbefa56ddbec35b0c58a7000fe97ebf (diff)
downloaddotty-a6a142e772b43fb44ba7086ba1005e983059285a.tar.gz
dotty-a6a142e772b43fb44ba7086ba1005e983059285a.tar.bz2
dotty-a6a142e772b43fb44ba7086ba1005e983059285a.zip
ExtractAPI: Add support for TypeLambdas
Before the new higher-kinded implementation this wasn't needed because lambdas were just RefinedTypes.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/sbt/ExtractAPI.scala15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/sbt/ExtractAPI.scala b/src/dotty/tools/dotc/sbt/ExtractAPI.scala
index a9586879f..caba96afa 100644
--- a/src/dotty/tools/dotc/sbt/ExtractAPI.scala
+++ b/src/dotty/tools/dotc/sbt/ExtractAPI.scala
@@ -174,9 +174,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
val name = if (sym.is(ModuleClass)) sym.fullName.sourceModuleName else sym.fullName
- val tparams = sym.typeParams.map(tparam => apiTypeParameter(
- tparam.name.toString, tparam.variance,
- tparam.info.bounds.lo, tparam.info.bounds.lo))
+ val tparams = sym.typeParams.map(apiTypeParameter)
val structure = apiClassStructure(sym)
@@ -364,6 +362,10 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
val apiTycon = simpleType(tycon)
val apiArgs = args.map(processArg)
new api.Parameterized(apiTycon, apiArgs.toArray)
+ case TypeLambda(tparams, res) =>
+ val apiTparams = tparams.map(apiTypeParameter)
+ val apiRes = apiType(res)
+ new api.Polymorphic(apiRes, apiTparams.toArray)
case rt: RefinedType =>
val name = rt.refinedName.toString
val parent = apiType(rt.parent)
@@ -409,12 +411,13 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
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).
new api.ParameterRef(tp.paramName.toString)
case tp: LazyRef =>
apiType(tp.ref)
case tp: TypeVar =>
apiType(tp.underlying)
- // !!! missing cases: TypeLambda, HKApply
case _ => {
ctx.warning(i"sbt-api: Unhandled type ${tp.getClass} : $tp")
Constants.emptyType
@@ -437,6 +440,10 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
new api.Singleton(new api.Path(pathComponents.toArray.reverse ++ Array(Constants.thisPath)))
}
+ def apiTypeParameter(tparam: TypeParamInfo): api.TypeParameter =
+ apiTypeParameter(tparam.paramName.toString, tparam.paramVariance,
+ tparam.paramBounds.lo, tparam.paramBounds.hi)
+
def apiTypeParameter(name: String, variance: Int, lo: Type, hi: Type): api.TypeParameter =
new api.TypeParameter(name, Array(), Array(), apiVariance(variance),
apiType(lo), apiType(hi))