Skip to content

Commit 6161eea

Browse files
committed
New method substApprox on types
1 parent c404b10 commit 6161eea

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ object SymDenotations {
17901790
case LambdaParam(_, _) :: _ =>
17911791
recur(tp.superType)
17921792
case tparams: List[Symbol @unchecked] =>
1793-
new ctx.SubstApproxMap(tparams, args).apply(recur(tycon))
1793+
recur(tycon).substApprox(tparams, args)
17941794
}
17951795
record(tp, baseTp)
17961796
baseTp

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,13 @@ object Types {
14431443
final def substSym(from: List[Symbol], to: List[Symbol])(implicit ctx: Context): Type =
14441444
ctx.substSym(this, from, to, null)
14451445

1446+
/** Substitute all occurrences of symbols in `from` by corresponding types in a`to`.
1447+
* Unlike `subst`, the `to` types here can be type bounds. A TypeBounds target
1448+
* will be replaced by range that gets absorbed in an approximating type map.
1449+
*/
1450+
final def substApprox(from: List[Symbol], to: List[Type])(implicit ctx: Context): Type =
1451+
new ctx.SubstApproxMap(from, to).apply(this)
1452+
14461453
// ----- misc -----------------------------------------------------------
14471454

14481455
/** Turn type into a function type.

0 commit comments

Comments
 (0)