Skip to content

Missing argument results in java.lang.VerifyError #24201

@soronpo

Description

@soronpo

Compiler version

v3.7.3

Minimized code

https://scastie.scala-lang.org/vkYYO4LJRP6eiBaiDqpCdg

abstract class Foo[T](defaultValue: => T, arg1: Int = 1, arg2: Int = 2):
  def getValue: T = defaultValue

enum Baz:
  case E1, E2

object Baz extends Foo[Baz](Baz.E1, arg2 = 2)

@main def test = println(Baz.getValue)

Output

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    Baz$.<init>()V @9: invokespecial
  Reason:
    Type uninitializedThis (current frame, stack[1]) is not assignable to 'Baz$'
  Current Frame:
    bci: @9
    flags: { flagThisUninit }
    locals: { uninitializedThis, integer }
    stack: { uninitializedThis, uninitializedThis }
  Bytecode:
    0000000: b200 22b6 0026 3c2a 2ab7 002a c000 2c1b
    0000010: b800 301b 05b7 0033 b1                 

	at main$package$.test(main.scala:9)
	at test.main(main.scala:9)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at sbt.Run.invokeMain(Run.scala:144)
	at sbt.Run.execute$1(Run.scala:94)
	at sbt.Run.$anonfun$runWithLoader$5(Run.scala:121)
	at sbt.Run$.executeSuccess(Run.scala:187)
	at sbt.Run.runWithLoader(Run.scala:121)
	at sbt.Run.run(Run.scala:128)
	at com.olegych.scastie.sbtscastie.SbtScastiePlugin$$anon$1.$anonfun$run$1(SbtScastiePlugin.scala:38)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:32)
	at sbt.ScastieTrapExit$App.run(ScastieTrapExit.scala:258)
	at java.base/java.lang.Thread.run(Thread.java:840)

Expectation

Prints E1.
Note that if we add arg1 = 1 or remove arg2 in Baz it works as expected.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions