Skip to content

Commit da5b3d8

Browse files
committed
Make constructor parameter $outer also Java synthetic
This does not work yet, since the backend does not issue a ACC_SYNTHETIC for parameters labeled Artifact.
1 parent 185f09e commit da5b3d8

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
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

tests/run/i14083.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ class Outer {
22
class Inner
33
}
44
@main def Test =
5+
assert(classOf[Outer#Inner]
6+
.getConstructors.head
7+
.getParameters.head
8+
.isSynthetic)
59
assert(
610
classOf[Outer#Inner]
711
.getDeclaredFields

0 commit comments

Comments
 (0)