Skip to content

Bad signature for private[this] field of value class type #7416

Closed
@odersky

Description

@odersky

How to reproduce:

In Line 26 of transform/CapturedVars.scala, change

private var Captured: Store.Location[collection.Set[Symbol]] = _

to

private[this] var Captured: Store.Location[collection.Set[Symbol]] = _

Compiling CapturedVars with -Xverify-signature gives

checking CapturedVars.scala after phase genSJSIR
-- Error: CapturedVars.scala:26:14 ---------------------------------------------
26 |  private var Captured: Store.Location[collection.Set[Symbol]] = _
   |              ^
   |compiler bug: created invalid generic signature for variable Captured in dotty.tools.dotc.transform.CapturedVars
   |signature: I
   |if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues
Error while emitting CapturedVars.scala
exception occurred while compiling CapturedVars.scala
java.lang.IllegalArgumentException: I: 'T' expected at index 0 while compiling CapturedVars.scala
Exception in thread "main" java.lang.IllegalArgumentException: I: 'T' expected at index 0
	at scala.tools.asm.util.CheckClassAdapter.checkChar(CheckClassAdapter.java:1018)
	at scala.tools.asm.util.CheckClassAdapter.checkTypeVariableSignature(CheckClassAdapter.java:951)
	at scala.tools.asm.util.CheckClassAdapter.checkFieldTypeSignature(CheckClassAdapter.java:859)
	at scala.tools.asm.util.CheckClassAdapter.checkFieldSignature(CheckClassAdapter.java:714)
	at dotty.tools.backend.jvm.DottyBackendInterface.verifySignature$$anonfun$1(DottyBackendInterface.scala:496)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.backend.jvm.DottyBackendInterface.wrap$1(DottyBackendInterface.scala:480)
	at dotty.tools.backend.jvm.DottyBackendInterface.verifySignature(DottyBackendInterface.scala:501)

It seems that the signature checker does not accept fields of primitive types (presumably, since a generic signature for such fields would be useless). In this case, the signature
comes from Store.Location which is a value class wrapping an Int.

If Captured is just private but not private[this], the signature is generated for the getter instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions