Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LPTK opened this issue Jun 14, 2018 · 3 comments

Comments

@LPTK
Copy link
Contributor

LPTK commented Jun 14, 2018

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)
@liufengyun
Copy link
Contributor

JVM has the restriction that before parent constructor call, this is not available. In this example, we are using this as a parameter to a super constructor call.

A fix is proposed in #6000, which is in the same spirit with the check in Scala 2.

@odersky
Copy link
Contributor

odersky commented Mar 1, 2019

I also had the VulpixUnitTest failing on me, like what happened in the CI failures here. I believe the "deadlock" test is flakey. Should we remove it?

@liufengyun
Copy link
Contributor

@odersky Just proposed a fix to the deadlock meta test: #6006 . I think it will fix the CI problem.

liufengyun added a commit to dotty-staging/dotty that referenced this issue Mar 6, 2019
liufengyun added a commit that referenced this issue Mar 6, 2019
Fix #4659: disallow reference to object itself in super calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants