Skip to content

Commit 22c3322

Browse files
authored
Merge pull request #14084 from dotty-staging/fix-14083
Make outer references Java-synthetic
2 parents c3f614b + da5b3d8 commit 22c3322

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
343343
def emitParamNames(jmethod: asm.MethodVisitor, params: List[Symbol]) =
344344
for param <- params do
345345
var access = asm.Opcodes.ACC_FINAL
346+
if param.is(Artifact) then access |= asm.Opcodes.ACC_SYNTHETIC
346347
jmethod.visitParameter(param.name.mangledString, access)
347348

348349
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ object Erasure {
929929
if constr.isConstructor && needsOuterParam(constr.owner.asClass) then
930930
constr.info match
931931
case MethodTpe(outerName :: _, outerType :: _, _) =>
932-
val outerSym = newSymbol(constr, outerName, Flags.Param, outerType)
932+
val outerSym = newSymbol(constr, outerName, Flags.Param | Flags.SyntheticArtifact, outerType)
933933
ValDef(outerSym) :: Nil
934934
case _ =>
935935
// There's a possible race condition that a constructor was looked at

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ object ExplicitOuter {
177177
else prefix.widen)
178178
val info = if (flags.is(Method)) ExprType(target) else target
179179
atPhaseNoEarlier(explicitOuterPhase.next) { // outer accessors are entered at explicitOuter + 1, should not be defined before.
180-
newSymbol(owner, name, Synthetic | flags, info, coord = cls.coord)
180+
newSymbol(owner, name, SyntheticArtifact | flags, info, coord = cls.coord)
181181
}
182182
}
183183

tests/run/i14083.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Outer {
2+
class Inner
3+
}
4+
@main def Test =
5+
assert(classOf[Outer#Inner]
6+
.getConstructors.head
7+
.getParameters.head
8+
.isSynthetic)
9+
assert(
10+
classOf[Outer#Inner]
11+
.getDeclaredFields
12+
.filter(_.getName == "$outer")
13+
.exists(_.isSynthetic))

0 commit comments

Comments
 (0)