Skip to content

Commit d34e3fa

Browse files
committed
Handle MatchTypeTrees in ExtractAPI
Also, fix creators for typed/untyped MatchTypeTrees
1 parent a345e9e commit d34e3fa

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
165165
def LambdaTypeTree(tparams: List[TypeDef], body: Tree)(implicit ctx: Context): LambdaTypeTree =
166166
ta.assignType(untpd.LambdaTypeTree(tparams, body), tparams, body)
167167

168+
def MatchTypeTree(bound: Tree, selector: Tree, cases: List[CaseDef])(implicit ctx: Context): MatchTypeTree =
169+
ta.assignType(untpd.MatchTypeTree(bound, selector, cases), bound, selector, cases)
170+
168171
def TypeBoundsTree(lo: Tree, hi: Tree)(implicit ctx: Context): TypeBoundsTree =
169172
ta.assignType(untpd.TypeBoundsTree(lo, hi), lo, hi)
170173

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ class TreeUnpickler(reader: TastyReader,
13831383
val fst = readUntyped()
13841384
val (bound, scrut) =
13851385
if (nextUnsharedTag == CASEDEF) (EmptyTree, fst) else (fst, readUntyped())
1386-
MatchTypeTree(bound, scrut, readCases(end))
1386+
untpd.MatchTypeTree(bound, scrut, readCases(end))
13871387
case TYPEBOUNDStpt =>
13881388
val lo = readUntyped()
13891389
val hi = ifBefore(end)(readUntyped(), lo)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
166166
api.Annotation.of(api.Constant.of(Constants.emptyType, name), Array())
167167
val orMarker = marker("Or")
168168
val byNameMarker = marker("ByName")
169-
169+
val matchMarker = marker("Match")
170170

171171
/** Extract the API representation of a source file */
172172
def apiSource(tree: Tree): Seq[api.ClassLike] = {
@@ -507,6 +507,9 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
507507
withMarker(s, orMarker)
508508
case ExprType(resultType) =>
509509
withMarker(apiType(resultType), byNameMarker)
510+
case MatchType(bound, scrut, cases) =>
511+
val s = combineApiTypes(apiType(bound) :: apiType(scrut) :: cases.map(apiType): _*)
512+
withMarker(s, matchMarker)
510513
case ConstantType(constant) =>
511514
api.Constant.of(apiType(constant.tpe), constant.stringValue)
512515
case AnnotatedType(tpe, annot) =>

0 commit comments

Comments
 (0)