Skip to content

Commit 750921e

Browse files
committed
Adapt class parameters in inlined code
1 parent 71dfd7f commit 750921e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,16 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
301301
private def registerType(tpe: Type): Unit = tpe match {
302302
case tpe: ThisType if !canElideThis(tpe) && !thisProxy.contains(tpe.cls) =>
303303
val proxyName = s"${tpe.cls.name}_this".toTermName
304+
def adaptToPrefix(tp: Type) = tp.asSeenFrom(inlineCallPrefix.tpe, inlinedMethod.owner)
304305
val proxyType = inlineCallPrefix.tpe.dealias.tryNormalize match {
305306
case typeMatchResult if typeMatchResult.exists => typeMatchResult
306-
case _ => tpe.asSeenFrom(inlineCallPrefix.tpe, inlinedMethod.owner).widenIfUnstable
307+
case _ => adaptToPrefix(tpe).widenIfUnstable
307308
}
308309
thisProxy(tpe.cls) = newSym(proxyName, InlineProxy, proxyType).termRef
309310
if (!tpe.cls.isStaticOwner)
310311
registerType(inlinedMethod.owner.thisType) // make sure we have a base from which to outer-select
312+
for (param <- tpe.cls.typeParams)
313+
paramProxy(param.typeRef) = adaptToPrefix(param.typeRef)
311314
case tpe: NamedType
312315
if tpe.symbol.is(Param) && tpe.symbol.owner == inlinedMethod && !paramProxy.contains(tpe) =>
313316
paramProxy(tpe) = paramBinding(tpe.name)

0 commit comments

Comments
 (0)