Skip to content

Commit a3fa2b2

Browse files
committed
Fix ctx and call of inlined opaque extension methods
1 parent abcee5b commit a3fa2b2

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ class TreeUnpickler(reader: TastyReader,
978978
def readLengthTerm(): Tree = {
979979
val end = readEnd()
980980

981-
def readBlock(mkTree: (List[Tree], Tree) => Tree): Tree = {
981+
def readBlock(mkTree: (List[Tree], Tree) => Tree)(implicit ctx: Context): Tree = {
982982
val exprReader = fork
983983
skipTree()
984984
val stats = readStats(ctx.owner, end)
@@ -1007,7 +1007,8 @@ class TreeUnpickler(reader: TastyReader,
10071007
readBlock(Block)
10081008
case INLINED =>
10091009
val call = readTerm()
1010-
readBlock((defs, expr) => Inlined(call, defs.asInstanceOf[List[MemberDef]], expr))
1010+
val inlineCtx = tpd.inlineContext(call)
1011+
readBlock((defs, expr) => Inlined(call, defs.asInstanceOf[List[MemberDef]], expr))(inlineCtx)
10111012
case IF =>
10121013
If(readTerm(), readTerm(), readTerm())
10131014
case LAMBDA =>

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
231231
// be duplicated
232232
// 2. To enable correct pickling (calls can share symbols with the inlined code, which
233233
// would trigger an assertion when pickling).
234-
val callTrace = Ident(call.symbol.topLevelClass.typeRef).withPos(call.pos)
234+
val symTrace =
235+
if (call.symbol.owner.companionOpaqueType.exists) call.symbol.owner
236+
else call.symbol.topLevelClass
237+
val callTrace = Ident(symTrace.typeRef).withPos(call.pos)
235238
cpy.Inlined(tree)(callTrace, transformSub(bindings), transform(expansion))
236239
case tree: Template =>
237240
withNoCheckNews(tree.parents.flatMap(newPart)) {

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class FromTastyTests extends ParallelTesting {
2929
val (step1, step2, step3) = compileTastyInDir("tests/pos", defaultOptions,
3030
blacklist = Set(
3131

32-
"opaque-immutable-array.scala",
33-
3432
"macro-deprecate-dont-touch-backquotedidents.scala",
3533
"t247.scala",
3634

0 commit comments

Comments
 (0)