Skip to content
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

Compiler crashes on a lazy val in a value class method #6358

Closed
scabug opened this issue Sep 11, 2012 · 18 comments
Closed

Compiler crashes on a lazy val in a value class method #6358

scabug opened this issue Sep 11, 2012 · 18 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Sep 11, 2012

class L(val t: Int) extends AnyVal {
   def lazyString = {
      lazy val x = t.toString
      () => x
   }
}
     while compiling: L.scala
        during phase: global=lambdalift, atPhase=constructors
     library version: version 2.10.0-20120906-172417-b7e08723d1
    compiler version: version 2.10.0-20120906-172417-b7e08723d1
  reconstructed args: -d out

  last tree to typer: Ident(bitmap$0$1)
              symbol: value bitmap$0$1 (flags: <param> <synthetic>)
   symbol definition: bitmap$0$1: runtime.VolatileByteRef
                 tpe: runtime.VolatileByteRef
       symbol owners: value bitmap$0$1 -> value x$lzycompute$1 -> method lazyString -> class L -> package <empty>
      context owners: value x$lzycompute$1 -> method lazyString -> class L -> package <empty>

== Enclosing template or block ==

DefDef( // final private[this] val x$lzycompute$1(): String
  <method> private final <local> <stable>
  "x$lzycompute"
  []
  List(Nil)
  <tpt> // tree.tpe=String
  Block( // tree.tpe=String
    Block( // tree.tpe=Unit
      Apply( // final def synchronized(x$1: Object): Object in class Object, tree.tpe=Object
        L.this."synchronized" // final def synchronized(x$1: Object): Object in class Object, tree.tpe=(x$1: Object)Object
        Block( // tree.tpe=runtime.BoxedUnit
          If( // tree.tpe=Unit
            Apply( // def ==(x: Int): Boolean in class Byte, tree.tpe=Boolean
              bitmap$0.&(1).$asInstanceOf[Byte]()."$eq$eq" // def ==(x: Int): Boolean in class Byte, tree.tpe=(x: Int)Boolean
              0
            )
            Block( // tree.tpe=Unit
              // 2 statements
              Assign( // tree.tpe=Unit
                "x$lzy" // lazy var x$lzy: String, tree.tpe=String
                Apply( // def toString(): String in class Object, tree.tpe=String
                  scala.Int.box($this)."toString" // def toString(): String in class Object, tree.tpe=()String
                  Nil
                )
              )
              Assign( // tree.tpe=Unit
                "bitmap$0" // var bitmap$0: runtime.VolatileByteRef, tree.tpe=Byte
                Apply( // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=Byte
                  TypeApply( // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=()Byte
                    bitmap$0.|(1)."$asInstanceOf" // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=[T0 >: ? <: ?]()T0
                    <tpt> // tree.tpe=Byte
                  )
                  Nil
                )
              )
              ()
            )
            <empty>
          )
          "scala"."runtime"."BoxedUnit"."UNIT" // final val UNIT: runtime.BoxedUnit in object BoxedUnit, tree.tpe=runtime.BoxedUnit
        )
      )
      ()
    )
    "x$lzy" // lazy var x$lzy: String, tree.tpe=String
  )
)

== Expanded type of tree ==

TypeRef(TypeSymbol(class VolatileByteRef extends Serializable))

unhandled exception while transforming L.scala
error: 
     while compiling: L.scala
        during phase: lambdalift
     library version: version 2.10.0-20120906-172417-b7e08723d1
    compiler version: version 2.10.0-20120906-172417-b7e08723d1
  reconstructed args: -d out

  last tree to typer: Ident(bitmap$0$1)
              symbol: value bitmap$0$1 (flags: <param> <synthetic>)
   symbol definition: bitmap$0$1: runtime.VolatileByteRef
                 tpe: runtime.VolatileByteRef
       symbol owners: value bitmap$0$1 -> value x$lzycompute$1 -> method lazyString -> class L -> package <empty>
      context owners: value x$lzycompute$1 -> method lazyString -> class L -> package <empty>

== Enclosing template or block ==

DefDef( // final private[this] val x$lzycompute$1(): String
  <method> private final <local> <stable>
  "x$lzycompute"
  []
  List(Nil)
  <tpt> // tree.tpe=String
  Block( // tree.tpe=String
    Block( // tree.tpe=Unit
      Apply( // final def synchronized(x$1: Object): Object in class Object, tree.tpe=Object
        L.this."synchronized" // final def synchronized(x$1: Object): Object in class Object, tree.tpe=(x$1: Object)Object
        Block( // tree.tpe=runtime.BoxedUnit
          If( // tree.tpe=Unit
            Apply( // def ==(x: Int): Boolean in class Byte, tree.tpe=Boolean
              bitmap$0.&(1).$asInstanceOf[Byte]()."$eq$eq" // def ==(x: Int): Boolean in class Byte, tree.tpe=(x: Int)Boolean
              0
            )
            Block( // tree.tpe=Unit
              // 2 statements
              Assign( // tree.tpe=Unit
                "x$lzy" // lazy var x$lzy: String, tree.tpe=String
                Apply( // def toString(): String in class Object, tree.tpe=String
                  scala.Int.box($this)."toString" // def toString(): String in class Object, tree.tpe=()String
                  Nil
                )
              )
              Assign( // tree.tpe=Unit
                "bitmap$0" // var bitmap$0: Byte, tree.tpe=Byte
                Apply( // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=Byte
                  TypeApply( // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=()Byte
                    bitmap$0.|(1)."$asInstanceOf" // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=[T0 >: ? <: ?]()T0
                    <tpt> // tree.tpe=Byte
                  )
                  Nil
                )
              )
              ()
            )
            <empty>
          )
          "scala"."runtime"."BoxedUnit"."UNIT" // final val UNIT: runtime.BoxedUnit in object BoxedUnit, tree.tpe=runtime.BoxedUnit
        )
      )
      ()
    )
    "x$lzy" // lazy var x$lzy: String, tree.tpe=String
  )
)

== Expanded type of tree ==

TypeRef(TypeSymbol(class VolatileByteRef extends Serializable))

uncaught exception during compilation: java.lang.IllegalArgumentException
error: java.lang.IllegalArgumentException: Could not find proxy for lazy var x$lzy: String in List(lazy value x$lzy, method extension$lazyString, object L, package <empty>, package <root>) (currentOwner= value x$lzycompute$1 )
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1(LambdaLift.scala:303)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.Option.getOrElse(Option.scala:120)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.Option.getOrElse(Option.scala:120)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.Option.getOrElse(Option.scala:120)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.Option.getOrElse(Option.scala:120)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
   at scala.Option.getOrElse(Option.scala:120)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1(LambdaLift.scala:308)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.proxy(LambdaLift.scala:317)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$proxyRef(LambdaLift.scala:333)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.postTransform(LambdaLift.scala:474)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1199)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:677)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:675)
   at scala.collection.immutable.List.loop$1(List.scala:164)
   at scala.collection.immutable.List.mapConserve(List.scala:180)
   at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:675)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:523)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1179)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1181)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:677)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:675)
   at scala.collection.immutable.List.loop$1(List.scala:164)
   at scala.collection.immutable.List.mapConserve(List.scala:180)
   at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:675)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:523)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1179)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:659)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:659)
   at scala.collection.immutable.List.loop$1(List.scala:164)
   at scala.collection.immutable.List.mapConserve(List.scala:180)
   at scala.reflect.api.Trees$Transformer.transformTrees(Trees.scala:659)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1160)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:677)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:675)
   at scala.collection.immutable.List.loop$1(List.scala:164)
   at scala.collection.immutable.List.mapConserve(List.scala:180)
   at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:675)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:523)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1179)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:677)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:675)
   at scala.collection.immutable.List.loop$1(List.scala:164)
   at scala.collection.immutable.List.mapConserve(List.scala:180)
   at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:675)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:523)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1179)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$$anonfun$itransform$2.apply(Trees.scala:1176)
   at scala.reflect.internal.Trees$$anonfun$itransform$2.apply(Trees.scala:1174)
   at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:34)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:28)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1173)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:677)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:675)
   at scala.collection.immutable.List.loop$1(List.scala:164)
   at scala.collection.immutable.List.mapConserve(List.scala:180)
   at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:675)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:523)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1179)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$$anonfun$itransform$2.apply(Trees.scala:1176)
   at scala.reflect.internal.Trees$$anonfun$itransform$2.apply(Trees.scala:1174)
   at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:34)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:28)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1173)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:677)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:675)
   at scala.collection.immutable.List.loop$1(List.scala:164)
   at scala.collection.immutable.List.mapConserve(List.scala:180)
   at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:675)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:523)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1217)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.scala$tools$nsc$transform$TypingTransformers$TypingTransformer$$super$transform(TypingTransformers.scala:44)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$1.apply(TypingTransformers.scala:44)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$1.apply(TypingTransformers.scala:44)
   at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:34)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:28)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:44)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer.transformTemplate(Trees.scala:661)
   at scala.reflect.internal.Trees$$anonfun$itransform$4.apply(Trees.scala:1221)
   at scala.reflect.internal.Trees$$anonfun$itransform$4.apply(Trees.scala:1220)
   at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:34)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:28)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1219)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:48)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:677)
   at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:675)
   at scala.collection.immutable.List.loop$1(List.scala:164)
   at scala.collection.immutable.List.mapConserve(List.scala:180)
   at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:675)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:523)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformStats(LambdaLift.scala:42)
   at scala.reflect.internal.Trees$$anonfun$itransform$7.apply(Trees.scala:1239)
   at scala.reflect.internal.Trees$$anonfun$itransform$7.apply(Trees.scala:1239)
   at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:34)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:28)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
   at scala.reflect.internal.Trees$class.itransform(Trees.scala:1238)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
   at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.scala$tools$nsc$transform$TypingTransformers$TypingTransformer$$super$transform(TypingTransformers.scala:44)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$2.apply(TypingTransformers.scala:46)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$2.apply(TypingTransformers.scala:46)
   at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:34)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:28)
   at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:46)
   at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:272)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.preTransform(LambdaLift.scala:496)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:504)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:42)
   at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:227)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$super$transformUnit(LambdaLift.scala:529)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$transformUnit$1.apply$mcV$sp(LambdaLift.scala:529)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$transformUnit$1.apply(LambdaLift.scala:529)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$transformUnit$1.apply(LambdaLift.scala:529)
   at scala.reflect.internal.SymbolTable.atPhase(SymbolTable.scala:199)
   at scala.reflect.internal.SymbolTable.afterPhase(SymbolTable.scala:208)
   at scala.tools.nsc.SubComponent.afterOwnPhase(SubComponent.scala:51)
   at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transformUnit(LambdaLift.scala:528)
   at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:30)
   at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:450)
   at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:417)
   at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:417)
   at scala.collection.Iterator$class.foreach(Iterator.scala:726)
   at scala.collection.AbstractIterator.foreach(Iterator.scala:1155)
   at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:417)
   at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1561)
   at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1535)
   at scala.tools.nsc.Global$Run.compileSources(Global.scala:1531)
   at scala.tools.nsc.Global$Run.compile(Global.scala:1641)
   at scala.tools.nsc.Driver.doCompile(Driver.scala:33)
   at scala.tools.nsc.Main$.doCompile(Main.scala:79)
   at scala.tools.nsc.Driver.process(Driver.scala:54)
   at scala.tools.nsc.Driver.main(Driver.scala:67)
   at scala.tools.nsc.Main.main(Main.scala)
@scabug
Copy link
Author

@scabug scabug commented Sep 11, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6358?orig=1
Reporter: @harrah
Affected Versions: 2.10.0-M7

@scabug
Copy link
Author

@scabug scabug commented Sep 13, 2012

@jsuereth said:
We at least need an error message here. Pass on as needed!

@scabug
Copy link
Author

@scabug scabug commented Sep 15, 2012

@retronym said:
Here's a proposed fix:

retronym/scala@2.10.x...ticket/6358

I'll add some more tests and submit a PR tomorrow.

@scabug
Copy link
Author

@scabug scabug commented Sep 15, 2012

@retronym said:
Well, that blows up pretty hard compiling, for example, GenSeqViewLike#FlatMapped:

[scalacfork] no method allowed here: value indexfalse <method> <deferred> <local> <stable> <accessor> lazy <triedcooking> <latedeferred> <notprotected>
[scalacfork] 	at scala.Predef$.assert(Predef.scala:173)
[scalacfork] 	at scala.tools.nsc.Global.assert(Global.scala:238)
[scalacfork] 	at scala.tools.nsc.transform.Mixin$MixinTransformer.scala$tools$nsc$transform$Mixin$MixinTransformer$$postTransform(Mixin.scala:1216)

@scabug
Copy link
Author

@scabug scabug commented Sep 16, 2012

@retronym said (edited on Sep 16, 2012 5:46:49 PM UTC):
I've refined the fix and documented exactly what goes wrong.

https://github.com/retronym/scala/compare/ticket/6358

Long story short:

  • extensionmethods only changes the owner of x$lzy to extension$lazyString
  • refchecks reintroduces the accessor x with it's original owner lazyString
  • calamity ensues.

My patch seems to work around this, but it isn't very appealing for the traversals like ChangeOwnerTraverser to follow Symbol#referenced in such an ad-hoc manner. Instead, could we mandate that we cannot remove a symbol definition from a tree only to add it again in a later phase? It would make it much harder to smuggle through untransformed symbols.

@scabug
Copy link
Author

@scabug scabug commented Sep 17, 2012

@harrah said:
With the change in scala/scala#1315, this no longer crashes. There is another problem involving type parameters:

class Y[T](val i: Option[T]) extends AnyVal {
   def q: List[T] = {
      lazy val e: List[T] = i.toList
      e
   }
}
Y.scala:2: error: type mismatch;
 found   : List[T(in method extension$q)]
 required: List[T(in class Y)]
   def q: List[T] = {
                    ^

It works for a normal val or def.

@scabug
Copy link
Author

@scabug scabug commented Sep 17, 2012

@scabug
Copy link
Author

@scabug scabug commented Sep 18, 2012

@odersky said:
Pull request closed. Marks example shows that the problem goes deeper. It seems in effect that we should not allow tunnelled definitions that get created at Typers without being introduced in the tree. Reassigning to Hubert.

@scabug
Copy link
Author

@scabug scabug commented Sep 19, 2012

@hubertp said:
It seems that this special treatment has been there since the very first version of lazy vals. I will try to move it to MethodSynthesis and see how they fit together.

@scabug
Copy link
Author

@scabug scabug commented Sep 23, 2012

@hubertp said:
So I managed to move generation of lazy val accessors to Typers in https://github.com/hubertp/scala-dev/tree/2.10.x-issue/6358. It was actually the local lazy vals which proved to be extremely annoying to adapt. I stumbled upon some reifier problems as well and fixed most of those (3 left to go). So apart from those all other tests pass, including the one for this bug.
Since I didn't know much before about Reifier it takes a bit longer to fix this thing but I am pretty close.

@scabug
Copy link
Author

@scabug scabug commented Sep 25, 2012

@scabug
Copy link
Author

@scabug scabug commented Sep 25, 2012

@hubertp said:
So I tested once again https://github.com/hubertp/scala-dev/tree/2.10.x-issue/6358 and fixed some position problems and that seems to work flawlessly (I also run rangepos build locally).
Since it was decided that it doesn't go into 2.10.0 I will wait but I hope that there aren't gonna be many conflicts once we decide to merge it.

@scabug
Copy link
Author

@scabug scabug commented Sep 25, 2012

@jsuereth said:
Can you post against master for now? I don't want this work to halt (unless you need to do other things), so I'll take care of backporting if you get it in master.

@scabug
Copy link
Author

@scabug scabug commented Sep 25, 2012

@hubertp said:
I could do that.

@scabug
Copy link
Author

@scabug scabug commented Sep 26, 2012

@scabug
Copy link
Author

@scabug scabug commented Oct 10, 2012

@hubertp said:
Josh, the fix landed in master. Feel free to backport it to 2.10.1.

@scabug
Copy link
Author

@scabug scabug commented Oct 10, 2012

@jsuereth said:
Ok, I'm taking ownership to backport the patch from master -> 2.10.1.

Thanks for the reminder! This will be a good test of my git cherry-pick skills.

@scabug
Copy link
Author

@scabug scabug commented Oct 21, 2012

@hubertp said:
Backported in scala/scala#1508

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants