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

DelayedInit crashes following $outer pointers

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.10.4-RC1, Scala 2.11.0-M8
    • Fix Version/s: None
    • Component/s: Misc Compiler
    • Environment:

      Scala 2.9.0.final

      Description

      [Elided, replaced.]

      class DelayedInitTest {
        def a = ()
        class B extends DelayedInit {
          a
          def delayedInit(body: => Unit) = ()
        }
      }
      
      scalac3 ./a.scala 
      error: java.lang.Error: symbol value $outer does not exist in DelayedInitTest$B$delayedInit$body.apply
      	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:31)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1027)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadQualifier(GenICode.scala:1175)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:921)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genStat(GenICode.scala:174)
      

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment -

          Another example:

          trait MatExpWorld { self =>
            class T extends Runner { val expWorld: self.type = self }
          }
          
          trait Runner extends DelayedInit {
            val expWorld: MatExpWorld
          }
          
          Show
          Jason Zaugg added a comment - Another example: trait MatExpWorld { self => class T extends Runner { val expWorld: self.type = self } } trait Runner extends DelayedInit { val expWorld: MatExpWorld }
          Hide
          James Iry added a comment -

          2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

          Show
          James Iry added a comment - 2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.
          Hide
          Jason Zaugg added a comment -

          One more example:

          class Entity extends DelayedInit {
           
            def delayedInit(x: => Unit) {x}
           
            class Field
           
            protected def EntityField[T <: Entity: Manifest] = new Field
           
            def find[T <: Entity: Manifest] {
              Nil.map(dbo => {
                class EntityHolder extends Entity {
                  val entity = EntityField[T]
                }
              })
            }
           
          }
          
          Show
          Jason Zaugg added a comment - One more example: class Entity extends DelayedInit { def delayedInit(x: => Unit) {x} class Field protected def EntityField[T <: Entity: Manifest] = new Field def find[T <: Entity: Manifest] { Nil.map(dbo => { class EntityHolder extends Entity { val entity = EntityField[T] } }) } }
          Hide
          Thornton Chamberlain added a comment -

          The following looks like it may be yet another manifestation of the same problem:

          trait T extends DelayedInit {
            def delayedInit(body: => Unit) = {
              println("In delayedInit")
              body
            }
          }
          val f = {(p1: Int) => new T{println(p1)}}
          f(5)
          

          In 2.10.3, this fails with 'error: symbol value p1$1 does not exist in $anonfun$1$$anon$1$delayedInit$body.apply'

          I encountered this when trying to use a Specs2 After context with a data table.

          Show
          Thornton Chamberlain added a comment - The following looks like it may be yet another manifestation of the same problem: trait T extends DelayedInit { def delayedInit(body: => Unit) = { println("In delayedInit") body } } val f = {(p1: Int) => new T{println(p1)}} f(5) In 2.10.3, this fails with 'error: symbol value p1$1 does not exist in $anonfun$1$$anon$1$delayedInit$body.apply' I encountered this when trying to use a Specs2 After context with a data table.
          Hide
          Jason Zaugg added a comment -

          The problem there is that the DelayedInit transformation happens in the 'constructors' compiler phase, by which point the prior 'lambdalift' phase has already decided that `p2` need not be retained in the anonymous subclass as `T` as a field. Looks mighty tricky to fix. I would recommend against building on top of DelayedInit.

          Show
          Jason Zaugg added a comment - The problem there is that the DelayedInit transformation happens in the 'constructors' compiler phase, by which point the prior 'lambdalift' phase has already decided that `p2` need not be retained in the anonymous subclass as `T` as a field. Looks mighty tricky to fix. I would recommend against building on top of DelayedInit.

            People

            • Assignee:
              Unassigned
              Reporter:
              Flávio W. Brasil
            • Votes:
              13 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

              • Created:
                Updated:

                Development