Skip to content

Commit 5e8eee3

Browse files
committed
Wrap type of accessors pointing to a module class into a TermRef
1 parent d87bbb1 commit 5e8eee3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,13 @@ abstract class AccessProxies {
141141
if accessorClass.is(Package) then
142142
accessorClass = ctx.owner.topLevelClass
143143
val accessorName = accessorNameOf(accessed.name, accessorClass)
144+
val mappedInfo = accessed.info match
145+
// TypeRef pointing to module class seems to not be stable, so we remap that to a TermRef
146+
// see test i22593.scala (and issue #i22593)
147+
case tref @ TypeRef(prefix, _) if tref.symbol.is(Module) => TermRef(prefix, tref.symbol.companionModule)
148+
case other => other
144149
val accessorInfo =
145-
accessed.info.ensureMethodic.asSeenFrom(accessorClass.thisType, accessed.owner)
150+
mappedInfo.ensureMethodic.asSeenFrom(accessorClass.thisType, accessed.owner)
146151
val accessor = accessorSymbol(accessorClass, accessorName, accessorInfo, accessed)
147152
rewire(reference, accessor)
148153
}

tests/pos/i22593.scala

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import scala.quoted.*
2+
3+
package jam {
4+
trait JamCoreDsl {
5+
implicit inline def defaultJamConfig: this.JamConfig =
6+
new JamConfig(brewRecRegex = ".*")
7+
class JamConfig(val brewRecRegex: String)
8+
inline def brew(implicit inline config: JamConfig): Unit = ???
9+
}
10+
private object internal extends JamCoreDsl
11+
export internal._
12+
}
13+
14+
object test {
15+
jam.brew
16+
}

0 commit comments

Comments
 (0)