Skip to content

Commit 068c6c7

Browse files
authored
Merge pull request #516 from scala/backport-lts-3.3-23126
Backport "Fix inline export forwarder generation regression" to 3.3 LTS
2 parents 8c6915c + 3b54482 commit 068c6c7

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,7 @@ object Types extends TypeUtils {
26832683
if (tparams.head.eq(tparam))
26842684
return args.head match {
26852685
case _: TypeBounds if !widenAbstract => TypeRef(pre, tparam)
2686-
case arg => arg
2686+
case arg => arg.boxedUnlessFun(tycon)
26872687
}
26882688
tparams = tparams.tail
26892689
args = args.tail

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/i22593a.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+
}

tests/pos/i22593b/Main.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 = ${ brewImpl() }
9+
}
10+
private object internal extends JamCoreDsl
11+
export internal._
12+
13+
def brewImpl(using q: Quotes)(): Expr[Unit] = {
14+
findSelf
15+
'{()}
16+
}
17+
18+
private def findSelf(using q: Quotes): Unit = {
19+
import q.reflect.*
20+
def rec(s: Symbol): Option[Symbol] = s.maybeOwner match {
21+
case o if o.isNoSymbol => None
22+
case o if o.isClassDef => Option(o)
23+
case o => rec(o)
24+
}
25+
rec(Symbol.spliceOwner)
26+
}
27+
}

tests/pos/i22593b/Test.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object CoreSpec {
2+
jam.brew
3+
}

0 commit comments

Comments
 (0)