Skip to content

Commit 3bdb053

Browse files
committed
Add reflect TypeRepr.substituteTypes
1 parent f4260b5 commit 3bdb053

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
16971697
dotc.core.Types.decorateTypeApplications(self).appliedTo(targ)
16981698
def appliedTo(targs: List[TypeRepr]): TypeRepr =
16991699
dotc.core.Types.decorateTypeApplications(self).appliedTo(targs)
1700+
def substituteTypes(from: List[Symbol], to: List[TypeRepr]): TypeRepr =
1701+
self.subst(from, to)
17001702
end extension
17011703
end TypeReprMethods
17021704

library/src/scala/quoted/Quotes.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,12 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
24742474
/** The current type applied to given type arguments: `this[targ0, ..., targN]` */
24752475
def appliedTo(targs: List[TypeRepr]): TypeRepr
24762476

2477+
/** Substitute all types that refer in their symbol attribute to
2478+
* one of the symbols in `from` by the corresponding types in `to`.
2479+
*/
2480+
@experimental
2481+
def substituteTypes(from: List[Symbol], to: List[TypeRepr]): TypeRepr
2482+
24772483
end extension
24782484
}
24792485

project/MiMaFilters.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ object MiMaFilters {
88
exclude[MissingClassProblem]("scala.annotation.internal.ProvisionalSuperClass"),
99

1010
// New APIs marked @experimental in 3.0.2
11-
exclude[MissingClassProblem]("scala.Selectable$WithoutPreciseParameterTypes")
11+
exclude[MissingClassProblem]("scala.Selectable$WithoutPreciseParameterTypes"),
12+
exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TypeReprMethods.substituteTypes"),
13+
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TypeReprMethods.substituteTypes"),
1214
)
1315
}

0 commit comments

Comments
 (0)