Skip to content

Commit a6a142e

Browse files
committed
ExtractAPI: Add support for TypeLambdas
Before the new higher-kinded implementation this wasn't needed because lambdas were just RefinedTypes.
1 parent 055726e commit a6a142e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
174174

175175
val name = if (sym.is(ModuleClass)) sym.fullName.sourceModuleName else sym.fullName
176176

177-
val tparams = sym.typeParams.map(tparam => apiTypeParameter(
178-
tparam.name.toString, tparam.variance,
179-
tparam.info.bounds.lo, tparam.info.bounds.lo))
177+
val tparams = sym.typeParams.map(apiTypeParameter)
180178

181179
val structure = apiClassStructure(sym)
182180

@@ -364,6 +362,10 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
364362
val apiTycon = simpleType(tycon)
365363
val apiArgs = args.map(processArg)
366364
new api.Parameterized(apiTycon, apiArgs.toArray)
365+
case TypeLambda(tparams, res) =>
366+
val apiTparams = tparams.map(apiTypeParameter)
367+
val apiRes = apiType(res)
368+
new api.Polymorphic(apiRes, apiTparams.toArray)
367369
case rt: RefinedType =>
368370
val name = rt.refinedName.toString
369371
val parent = apiType(rt.parent)
@@ -409,12 +411,13 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
409411
case RecThis(binder) =>
410412
apiThis(binder.typeSymbol) // !!! this is almost certainly wrong: binder does not always have a typeSymbol !!!
411413
case tp: ParamType =>
414+
// TODO: Distinguishing parameters based on their names alone is not enough,
415+
// the binder is also needed (at least for type lambdas).
412416
new api.ParameterRef(tp.paramName.toString)
413417
case tp: LazyRef =>
414418
apiType(tp.ref)
415419
case tp: TypeVar =>
416420
apiType(tp.underlying)
417-
// !!! missing cases: TypeLambda, HKApply
418421
case _ => {
419422
ctx.warning(i"sbt-api: Unhandled type ${tp.getClass} : $tp")
420423
Constants.emptyType
@@ -437,6 +440,10 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
437440
new api.Singleton(new api.Path(pathComponents.toArray.reverse ++ Array(Constants.thisPath)))
438441
}
439442

443+
def apiTypeParameter(tparam: TypeParamInfo): api.TypeParameter =
444+
apiTypeParameter(tparam.paramName.toString, tparam.paramVariance,
445+
tparam.paramBounds.lo, tparam.paramBounds.hi)
446+
440447
def apiTypeParameter(name: String, variance: Int, lo: Type, hi: Type): api.TypeParameter =
441448
new api.TypeParameter(name, Array(), Array(), apiVariance(variance),
442449
apiType(lo), apiType(hi))

0 commit comments

Comments
 (0)