Skip to content

Weird dependent class instantiation crashes with java.lang.VerifyError: Bad type on operand stack #4659

Closed
@LPTK

Description

@LPTK
sbt:dotty> repl
[info] Running (fork) dotty.tools.repl.Main -classpath dotty/library/target/scala-2.12/dotty-library_2.12-0.9.0-bin-SNAPSHOT-nonbootstrapped.jar

scala> class A(val a:A)(val b:a.T){type T}
// defined class A

scala> object a0 extends A(a0)(0){type T = Int}
// defined object a0

scala> new A(a0)(1)
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    rs$line$5$a0$.<init>()V @6: invokespecial
  Reason:
    Type uninitializedThis (current frame, stack[1]) is not assignable to 'rs$line$4$A
  Current Frame:
    bci: @6
    flags: { flagThisUninit }
    locals: { uninitializedThis }
    stack: { uninitializedThis, uninitializedThis, 'java/lang/Integer }
  Bytecode:
    0x0000000: 2a2a 03b8 0017 b700 1a2a b300 1cb1

	at rs$line$6$.<init>(rs$line$6:1)
	at rs$line$6$.<clinit>(rs$line$6)
	at rs$line$6.res0(rs$line$6)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at dotty.tools.repl.Rendering.$anonfun$valueOf$2(Rendering.scala:57)
	at scala.Option.map(Option.scala:146)
	at dotty.tools.repl.Rendering.valueOf(Rendering.scala:57)
	at dotty.tools.repl.Rendering.renderVal(Rendering.scala:86)
	at dotty.tools.repl.ReplDriver.$anonfun$displayDefinitions$8(ReplDriver.scala:288)
	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
	at scala.collection.TraversableLike.map(TraversableLike.scala:234)
	at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
	at scala.collection.AbstractTraversable.map(Traversable.scala:104)
	at dotty.tools.repl.ReplDriver.displayMembers$1(ReplDriver.scala:288)
	at dotty.tools.repl.ReplDriver.$anonfun$displayDefinitions$15(ReplDriver.scala:315)
	at scala.Option.map(Option.scala:146)
	at dotty.tools.repl.ReplDriver.$anonfun$displayDefinitions$13(ReplDriver.scala:313)
	at dotty.tools.dotc.core.Periods.atPhase(Periods.scala:26)
	at dotty.tools.dotc.core.Phases.atPhase(Phases.scala:36)
	at dotty.tools.dotc.core.Phases.atPhase$(Phases.scala:35)
	at dotty.tools.dotc.core.Contexts$Context.atPhase(Contexts.scala:71)
	at dotty.tools.repl.ReplDriver.displayDefinitions(ReplDriver.scala:308)
	at dotty.tools.repl.ReplDriver.$anonfun$compile$2(ReplDriver.scala:245)
	at scala.util.Either.fold(Either.scala:188)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:236)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:203)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:150)
	at dotty.tools.repl.ReplDriver.$anonfun$runUntilQuit$1(ReplDriver.scala:154)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
	at scala.Console$.withErr(Console.scala:192)
	at dotty.tools.repl.ReplDriver.$anonfun$withRedirectedOutput$1(ReplDriver.scala:163)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
	at scala.Console$.withOut(Console.scala:163)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:163)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:154)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions