Skip to content

Commit d5fa3f2

Browse files
committed
Fix owner of package definition in TreeMapWithImplicits
1 parent 20ff611 commit d5fa3f2

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

compiler/src/dotty/tools/dotc/ast/TreeMapWithImplicits.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ class TreeMapWithImplicits extends tpd.TreeMap {
106106
}
107107
case EmptyValDef =>
108108
tree
109-
case _: PackageDef | _: MemberDef =>
109+
case _: MemberDef =>
110110
super.transform(tree)(using localCtx)
111+
case _: PackageDef =>
112+
super.transform(tree)(using ctx.withOwner(tree.symbol.moduleClass))
111113
case impl @ Template(constr, parents, self, _) =>
112114
cpy.Template(tree)(
113115
transformSub(constr),

tests/pos-macros/i11479/Macro_1.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Foo
2+
given Foo: Foo with {}
3+
inline def summonFoo(): Foo = scala.compiletime.summonInline[Foo]
4+
5+
package p:
6+
trait Bar
7+
given Bar: Bar with {}
8+
inline def summonBar(): Bar = scala.compiletime.summonInline[Bar]
9+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package p
2+
def test3: Unit = summonBar()

tests/pos-macros/i11479/Test_2.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import p.{*, given}
2+
def test: Unit =
3+
summonFoo()
4+
summonBar()
5+
6+
7+
8+

0 commit comments

Comments
 (0)