Skip to content

Commit 9da1b1e

Browse files
jchybtgodzik
authored andcommitted
Wrap type of accessors pointing to a module class into a TermRef
[Cherry-picked 2c896f1]
1 parent 0214f81 commit 9da1b1e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,13 @@ abstract class AccessProxies {
136136
if accessorClass.is(Package) then
137137
accessorClass = ctx.owner.topLevelClass
138138
val accessorName = accessorNameOf(accessed.name, accessorClass)
139+
val mappedInfo = accessed.info match
140+
// TypeRef pointing to module class seems to not be stable, so we remap that to a TermRef
141+
// see test i22593.scala (and issue #i22593)
142+
case tref @ TypeRef(prefix, _) if tref.symbol.is(Module) => TermRef(prefix, tref.symbol.companionModule)
143+
case other => other
139144
val accessorInfo =
140-
accessed.info.ensureMethodic.asSeenFrom(accessorClass.thisType, accessed.owner)
145+
mappedInfo.ensureMethodic.asSeenFrom(accessorClass.thisType, accessed.owner)
141146
val accessor = accessorSymbol(accessorClass, accessorName, accessorInfo, accessed)
142147
rewire(reference, accessor)
143148
}

tests/pos/i22593.scala

Lines changed: 16 additions & 0 deletions
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)