Skip to content

Commit 5dd9909

Browse files
retronymmilessabin
authored andcommitted
Adjust owner of byname implicit RHS
An implicit macro within the by-name implicit dictionary might return a typechecked tree, so we ought to use changeOwner when moving that code into the RHS of a synthetic member of `LazyDefns`
1 parent 5b480f0 commit 5dd9909

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/scala/tools/nsc/typechecker/Contexts.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ trait Contexts { self: Analyzer =>
320320
if(pruned.isEmpty) result
321321
else {
322322
val (vsyms, vdefs) = pruned.map { case (vsym, rhs) =>
323-
(vsym, ValDef(Modifiers(FINAL | SYNTHETIC), vsym.name.toTermName, TypeTree(rhs.tpe), rhs))
323+
(vsym, ValDef(Modifiers(FINAL | SYNTHETIC), vsym.name.toTermName, TypeTree(rhs.tpe), rhs.changeOwner(owner -> vsym)))
324324
}.unzip
325325

326326
val ctor = DefDef(NoMods, nme.CONSTRUCTOR, Nil, ListOfNil, TypeTree(), Block(List(pendingSuperCall), Literal(Constant(()))))
@@ -352,7 +352,7 @@ trait Contexts { self: Analyzer =>
352352
}
353353

354354
val tree0 = patchRefs.transform(result.tree)
355-
val tree1 = Block(mdef0, tree0).substituteSymbols(vsyms.toList, vsyms0.toList) setType tree.tpe
355+
val tree1 = Block(mdef0, tree0).substituteSymbols(vsyms, vsyms0) setType tree.tpe
356356

357357
new SearchResult(atPos(pos.focus)(tree1), result.subst, result.undetparams)
358358
}

0 commit comments

Comments
 (0)