Skip to content

Commit b1848c0

Browse files
committed
Do not remove accessors to early
Accessors that are added to packages were removed to early from `accessedBy`. This resulted in a new symbol beeing entered for the same accessor. Fixes #13476
1 parent 02642db commit b1848c0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ abstract class AccessProxies {
3131
*/
3232
protected def passReceiverAsArg(accessorName: Name)(using Context): Boolean = false
3333

34-
/** The accessor definitions that need to be added to class `cls`
35-
* As a side-effect, this method removes entries from the `accessedBy` map.
36-
* So a second call of the same method will yield the empty list.
37-
*/
34+
/** The accessor definitions that need to be added to class `cls` */
3835
private def accessorDefs(cls: Symbol)(using Context): Iterator[DefDef] =
39-
for (accessor <- cls.info.decls.iterator; accessed <- accessedBy.remove(accessor).toOption) yield
36+
for accessor <- cls.info.decls.iterator; accessed <- accessedBy.get(accessor) yield
4037
DefDef(accessor.asTerm, prefss => {
4138
def numTypeParams = accessed.info match {
4239
case info: PolyType => info.paramNames.length

tests/pos/i13476.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
private object Foo:
2+
inline def d(arg : Int): Unit = {}
3+
transparent inline def haha() : Unit = {}
4+
5+
export Foo.*
6+
7+
@main def main : Unit = haha()

0 commit comments

Comments
 (0)