Scala Programming Language
  1. Scala Programming Language
  2. SI-6506

VerifyError with anon class passed to right assoc method in constructor argument of anon class that extends trait

    Details

      Description

      https://github.com/espringe/wisp/blob/04a2c643933b0fec871ba186e233da0019802ebe/src/main/scala/wisp/reader.scala#L64

      If you remove that temporary variable (and put the statement inline), the code the compiler generates results in:

      Caught1: java.lang.VerifyError: (class:
      wisp/Reader$$anonfun$wisp$Reader$$literalListParser$1$$anonfun$apply$36$$anon$7,
      method: <init> signature:
      (Lwisp/Reader$$anonfun$wisp$Reader$$literalListParser$1$$anonfun$apply$36;Lscala/collection/immutable/List;)V)
      Expecting to find object/array on stack

      Easy enough to reproduce:

      $ git clone git@github.com:espringe/wisp.git
      $ cd wisp && git checkout 04a2c643933b0fe
      $ sbt test # all works fine
      // remove tmp variable /src/main/scala/wisp/reader.scala:L64
      $ sbt test # watch it asplode

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment -
          
          [info] Resolving org.specs2#specs2_2.10.0-M7;1.13-SNAPSHOT ...
          [warn] 	module not found: org.specs2#specs2_2.10.0-M7;1.13-SNAPSHOT
          [warn] ==== local: tried
          [warn]   /Users/jason/.ivy2/local/org.specs2/specs2_2.10.0-M7/1.13-SNAPSHOT/ivys/ivy.xml
          [warn] ==== Sonatype OSS Snapshots: tried
          [warn]   https://oss.sonatype.org/content/repositories/snapshots/org/specs2/specs2_2.10.0-M7/1.13-SNAPSHOT/specs2_2.10.0-M7-1.13-SNAPSHOT.pom
          [warn] ==== public: tried
          [warn]   http://repo1.maven.org/maven2/org/specs2/specs2_2.10.0-M7/1.13-SNAPSHOT/specs2_2.10.0-M7-1.13-SNAPSHOT.pom
          [warn] 	::::::::::::::::::::::::::::::::::::::::::::::
          [warn] 	::          UNRESOLVED DEPENDENCIES         ::
          [warn] 	::::::::::::::::::::::::::::::::::::::::::::::
          [warn] 	:: org.specs2#specs2_2.10.0-M7;1.13-SNAPSHOT: not found
          [warn] 	::::::::::::::::::::::::::::::::::::::::::::::
          [error] {file:/Users/jason/code/wisp/}default-5a12e1/*:update: sbt.ResolveException: unresolved dependency: org.specs2#specs2_2.10.0-M7;1.13-SNAPSHOT: not found
          [error] Total time: 3 s, completed Oct 11, 2012 8:19:15 AM
          
          Show
          Jason Zaugg added a comment - [info] Resolving org.specs2#specs2_2.10.0-M7;1.13-SNAPSHOT ... [warn] module not found: org.specs2#specs2_2.10.0-M7;1.13-SNAPSHOT [warn] ==== local: tried [warn] /Users/jason/.ivy2/local/org.specs2/specs2_2.10.0-M7/1.13-SNAPSHOT/ivys/ivy.xml [warn] ==== Sonatype OSS Snapshots: tried [warn] https://oss.sonatype.org/content/repositories/snapshots/org/specs2/specs2_2.10.0-M7/1.13-SNAPSHOT/specs2_2.10.0-M7-1.13-SNAPSHOT.pom [warn] ==== public: tried [warn] http://repo1.maven.org/maven2/org/specs2/specs2_2.10.0-M7/1.13-SNAPSHOT/specs2_2.10.0-M7-1.13-SNAPSHOT.pom [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: org.specs2#specs2_2.10.0-M7;1.13-SNAPSHOT: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: [error] {file:/Users/jason/code/wisp/}default-5a12e1/*:update: sbt.ResolveException: unresolved dependency: org.specs2#specs2_2.10.0-M7;1.13-SNAPSHOT: not found [error] Total time: 3 s, completed Oct 11, 2012 8:19:15 AM
          Hide
          Jason Zaugg added a comment -

          I can reproduce by changing the Specs version and forcing use of Java 7.

          https://gist.github.com/3870578

          Show
          Jason Zaugg added a comment - I can reproduce by changing the Specs version and forcing use of Java 7. https://gist.github.com/3870578
          Hide
          Jason Zaugg added a comment - - edited

          Here's a minimization. Demonstrated in 2.8.1; this isn't a regression.

           ~/code/scala scala28
          Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27).
          Type in expressions to have them evaluated.
          Type :help for more information.
          
          scala> object S { def #::(a: Any): Any = () }              
          defined module S
          
          scala> trait T; class WL(a: Any); new WL(new {} #:: S) with T 
          java.lang.VerifyError: (class: $anon$1, method: <init> signature: ()V) Expecting to find object/array on stack
          	at .<init>(<console>:8)
          
          scala> trait T; class WL(a: Any); new WL(S.#::(new {})) with T
          defined trait T
          defined class WL
          
          scala> class WL(a: Any); new WL(new {} #:: S)           
          defined class WL
          
          scala> trait T; class WL(a: Any); object X extends WL(new {} #:: S) with T; X     
          defined trait T
          defined class WL
          defined module X
          
          Show
          Jason Zaugg added a comment - - edited Here's a minimization. Demonstrated in 2.8.1; this isn't a regression. ~/code/scala scala28 Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27). Type in expressions to have them evaluated. Type :help for more information. scala> object S { def #::(a: Any): Any = () } defined module S scala> trait T; class WL(a: Any); new WL(new {} #:: S) with T java.lang.VerifyError: (class: $anon$1, method: <init> signature: ()V) Expecting to find object/array on stack at .<init>(<console>:8) scala> trait T; class WL(a: Any); new WL(S.#::(new {})) with T defined trait T defined class WL scala> class WL(a: Any); new WL(new {} #:: S) defined class WL scala> trait T; class WL(a: Any); object X extends WL(new {} #:: S) with T; X defined trait T defined class WL defined module X
          Hide
          Grzegorz Kossakowski added a comment -

          I heard from James Iry that Jason is looking into this problem so I'm reassigning it.

          My opinion is that we should reject declaring classes in super constructor calls.

          Show
          Grzegorz Kossakowski added a comment - I heard from James Iry that Jason is looking into this problem so I'm reassigning it. My opinion is that we should reject declaring classes in super constructor calls.
          Hide
          Jason Zaugg added a comment -

          Looks like a variation of SI-6666.

          Show
          Jason Zaugg added a comment - Looks like a variation of SI-6666 .

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Eric Springer
            • Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development