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 crash with trait inside method (part I: add implementation restriction) #6231

Closed
scabug opened this issue Aug 14, 2012 · 7 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Aug 14, 2012

Sorry the summary isn't great; this crashed the compiler, it's as minimized as I could get it from my original encounter.

object Bug {
  def foo[V: Ordered] {}

  def bar[V: Ordered] {
//    object Scope {
      trait X {
        def qux = { i: Any => foo }
      }
//    }
  }
}

causes a compiler crash under both 2.9.2 and 2.10.0-M6. Uncommenting the two commented lines allows us to work around this issue for now.

The output from M6 is:

[info] Compiling 41 Scala sources and 1 Java source to /Users/scott/projects/toolkit/algebra/target/scala-2.10.0-M6/classes...
[error] No getter for value evidence$2$1 in trait Bug$X$1

     while compiling: /Users/scott/projects/toolkit/algebra/src/main/scala/net/tqft/toolkit/algebra/Bug.scala
        during phase: mixin
     library version: version 2.10.0-M6
    compiler version: version 2.10.0-M6
  reconstructed args: -d /Users/scott/projects/toolkit/algebra/target/scala-2.10.0-M6/classes -classpath /Users/scott/projects/toolkit/algebra/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/base/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/arithmetic/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/functions/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/collections/target/scala-2.10.0-M6/classes:/Users/scott/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:/Users/scott/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.6.1.jar:/Users/scott/.ivy2/cache/log4j/log4j/bundles/log4j-1.2.16.jar:/Users/scott/.ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar:/Users/scott/.ivy2/cache/com.google.guava/guava/jars/guava-12.0.jar:/Users/scott/.ivy2/cache/com.google.code.findbugs/jsr305/jars/jsr305-1.3.9.jar:/Users/scott/.ivy2/cache/org.apache.commons/commons-math/jars/commons-math-2.2.jar:/Users/scott/.ivy2/cache/org.apfloat/apfloat/jars/apfloat-1.6.3.jar -bootclasspath /Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jsfd.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/ui.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/laf.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/sunrsasign.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jsse.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jce.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/charsets.jar:/Users/scott/.sbt/boot/scala-2.10.0-M6/lib/scala-library.jar

  last tree to typer: Ident(positions$1)
              symbol: value positions$1 (flags: <param> <synthetic> <triedcooking>)
   symbol definition: positions$1: scala.collection.immutable.IndexedSeq
                 tpe: scala.collection.immutable.IndexedSeq
       symbol owners: value positions$1 -> constructor Permutations$$anonfun$preserving$1 -> anonymous class Permutations$$anonfun$preserving$1 -> package permutations
      context owners: anonymous class Bug$X$1$$anonfun$qux$1 -> package algebra

== Enclosing template or block ==

Template( // val <local $anonfun>: <notype>, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
  "scala.runtime.AbstractFunction1$mcVL$sp", "scala.Serializable" // parents
  ValDef(
    private
    "_"
    <tpt>
    <empty>
  )
  // 3 statements
  DefDef( // final def apply(x$1: Object): Unit
    <method> final <triedcooking>
    "apply"
    []
    // 1 parameter list
    ValDef( // i: Object
      <param>
      "i"
      <tpt> // tree.tpe=Object
      <empty>
    )
    <tpt> // tree.tpe=Unit
    Apply( // def foo(evidence$1: scala.math.Ordered): Unit in object Bug, tree.tpe=Unit
      Bug.this."foo" // def foo(evidence$1: scala.math.Ordered): Unit in object Bug, tree.tpe=(evidence$1: scala.math.Ordered)Unit
      Bug$X$1$$anonfun$qux$1.this."$outer "."evidence$2$1" // val evidence$2$1: scala.math.Ordered in class Bug$X$1$class, tree.tpe=scala.math.Ordered
    )
  )
  DefDef( // final def apply(v1: Object): Object
    <method> final <bridge>
    "apply"
    []
    // 1 parameter list
    ValDef( // v1: Object
      <param> <triedcooking>
      "v1"
      <tpt> // tree.tpe=Object
      <empty>
    )
    <tpt> // tree.tpe=Object
    Block( // tree.tpe=scala.runtime.BoxedUnit
      Apply( // final def apply(x$1: Object): Unit, tree.tpe=Unit
        Bug$X$1$$anonfun$qux$1.this."apply" // final def apply(x$1: Object): Unit, tree.tpe=(x$1: Object)Unit
        "v1" // v1: Object, tree.tpe=Object
      )
      "scala"."runtime"."BoxedUnit"."UNIT" // final val UNIT: scala.runtime.BoxedUnit in object BoxedUnit, tree.tpe=scala.runtime.BoxedUnit
    )
  )
  DefDef( // def <init>(arg$outer: net.tqft.toolkit.algebra.Bug$X$1): net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
    <method> <triedcooking>
    "<init>"
    []
    // 1 parameter list
    ValDef( // $outer: net.tqft.toolkit.algebra.Bug$X$1
      <param> <triedcooking>
      "$outer"
      <tpt> // tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
      <empty>
    )
    <tpt> // tree.tpe=net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
    Block( // tree.tpe=Unit
      // 2 statements
      If( // tree.tpe=Unit
        Apply( // final def eq(x$1: Object): Boolean in class Object, tree.tpe=Boolean
          "$outer"."eq" // final def eq(x$1: Object): Boolean in class Object, tree.tpe=(x$1: Object)Boolean
          null
        )
        Throw( // tree.tpe=Nothing
          Apply( // def <init>(): NullPointerException in class NullPointerException, tree.tpe=NullPointerException
            new NullPointerException."<init>" // def <init>(): NullPointerException in class NullPointerException, tree.tpe=()NullPointerException
            Nil
          )
        )
        Assign( // tree.tpe=Unit
          Bug$X$1$$anonfun$qux$1.this."$outer " // private[this] val $outer: net.tqft.toolkit.algebra.Bug$X$1, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
          "$outer" // $outer: net.tqft.toolkit.algebra.Bug$X$1, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
        )
      )
      Apply( // def <init>(): scala.runtime.AbstractFunction1$mcVL$sp in class AbstractFunction1$mcVL$sp, tree.tpe=scala.runtime.AbstractFunction1$mcVL$sp
        Bug$X$1$$anonfun$qux$1.super."<init>" // def <init>(): scala.runtime.AbstractFunction1$mcVL$sp in class AbstractFunction1$mcVL$sp, tree.tpe=()scala.runtime.AbstractFunction1$mcVL$sp
        Nil
      )
      ()
    )
  )
)

== Expanded type of tree ==

TypeRef(
  TypeSymbol(
    abstract trait IndexedSeq extends Seq with IndexedSeq with GenericTraversableTemplate with IndexedSeqLike
    
  )
)

unhandled exception while transforming Bug.scala
[error] 
[error]      while compiling: /Users/scott/projects/toolkit/algebra/src/main/scala/net/tqft/toolkit/algebra/Bug.scala
[error]         during phase: mixin
[error]      library version: version 2.10.0-M6
[error]     compiler version: version 2.10.0-M6
[error]   reconstructed args: -d /Users/scott/projects/toolkit/algebra/target/scala-2.10.0-M6/classes -classpath /Users/scott/projects/toolkit/algebra/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/base/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/arithmetic/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/functions/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/collections/target/scala-2.10.0-M6/classes:/Users/scott/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:/Users/scott/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.6.1.jar:/Users/scott/.ivy2/cache/log4j/log4j/bundles/log4j-1.2.16.jar:/Users/scott/.ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar:/Users/scott/.ivy2/cache/com.google.guava/guava/jars/guava-12.0.jar:/Users/scott/.ivy2/cache/com.google.code.findbugs/jsr305/jars/jsr305-1.3.9.jar:/Users/scott/.ivy2/cache/org.apache.commons/commons-math/jars/commons-math-2.2.jar:/Users/scott/.ivy2/cache/org.apfloat/apfloat/jars/apfloat-1.6.3.jar -bootclasspath /Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jsfd.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/ui.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/laf.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/sunrsasign.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jsse.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jce.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/charsets.jar:/Users/scott/.sbt/boot/scala-2.10.0-M6/lib/scala-library.jar
[error] 
[error]   last tree to typer: Ident(positions$1)
[error]               symbol: value positions$1 (flags: <param> <synthetic> <triedcooking>)
[error]    symbol definition: positions$1: scala.collection.immutable.IndexedSeq
[error]                  tpe: scala.collection.immutable.IndexedSeq
[error]        symbol owners: value positions$1 -> constructor Permutations$$anonfun$preserving$1 -> anonymous class Permutations$$anonfun$preserving$1 -> package permutations
[error]       context owners: anonymous class Bug$X$1$$anonfun$qux$1 -> package algebra
[error] 
[error] == Enclosing template or block ==
[error] 
[error] Template( // val <local $anonfun>: <notype>, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
[error]   "scala.runtime.AbstractFunction1$mcVL$sp", "scala.Serializable" // parents
[error]   ValDef(
[error]     private
[error]     "_"
[error]     <tpt>
[error]     <empty>
[error]   )
[error]   // 3 statements
[error]   DefDef( // final def apply(x$1: Object): Unit
[error]     <method> final <triedcooking>
[error]     "apply"
[error]     []
[error]     // 1 parameter list
[error]     ValDef( // i: Object
[error]       <param>
[error]       "i"
[error]       <tpt> // tree.tpe=Object
[error]       <empty>
[error]     )
[error]     <tpt> // tree.tpe=Unit
[error]     Apply( // def foo(evidence$1: scala.math.Ordered): Unit in object Bug, tree.tpe=Unit
[error]       Bug.this."foo" // def foo(evidence$1: scala.math.Ordered): Unit in object Bug, tree.tpe=(evidence$1: scala.math.Ordered)Unit
[error]       Bug$X$1$$anonfun$qux$1.this."$outer "."evidence$2$1" // val evidence$2$1: scala.math.Ordered in class Bug$X$1$class, tree.tpe=scala.math.Ordered
[error]     )
[error]   )
[error]   DefDef( // final def apply(v1: Object): Object
[error]     <method> final <bridge>
[error]     "apply"
[error]     []
[error]     // 1 parameter list
[error]     ValDef( // v1: Object
[error]       <param> <triedcooking>
[error]       "v1"
[error]       <tpt> // tree.tpe=Object
[error]       <empty>
[error]     )
[error]     <tpt> // tree.tpe=Object
[error]     Block( // tree.tpe=scala.runtime.BoxedUnit
[error]       Apply( // final def apply(x$1: Object): Unit, tree.tpe=Unit
[error]         Bug$X$1$$anonfun$qux$1.this."apply" // final def apply(x$1: Object): Unit, tree.tpe=(x$1: Object)Unit
[error]         "v1" // v1: Object, tree.tpe=Object
[error]       )
[error]       "scala"."runtime"."BoxedUnit"."UNIT" // final val UNIT: scala.runtime.BoxedUnit in object BoxedUnit, tree.tpe=scala.runtime.BoxedUnit
[error]     )
[error]   )
[error]   DefDef( // def <init>(arg$outer: net.tqft.toolkit.algebra.Bug$X$1): net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
[error]     <method> <triedcooking>
[error]     "<init>"
[error]     []
[error]     // 1 parameter list
[error]     ValDef( // $outer: net.tqft.toolkit.algebra.Bug$X$1
[error]       <param> <triedcooking>
[error]       "$outer"
[error]       <tpt> // tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
[error]       <empty>
[error]     )
[error]     <tpt> // tree.tpe=net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
[error]     Block( // tree.tpe=Unit
[error]       // 2 statements
[error]       If( // tree.tpe=Unit
[error]         Apply( // final def eq(x$1: Object): Boolean in class Object, tree.tpe=Boolean
[error]           "$outer"."eq" // final def eq(x$1: Object): Boolean in class Object, tree.tpe=(x$1: Object)Boolean
[error]           null
[error]         )
[error]         Throw( // tree.tpe=Nothing
[error]           Apply( // def <init>(): NullPointerException in class NullPointerException, tree.tpe=NullPointerException
[error]             new NullPointerException."<init>" // def <init>(): NullPointerException in class NullPointerException, tree.tpe=()NullPointerException
[error]             Nil
[error]           )
[error]         )
[error]         Assign( // tree.tpe=Unit
[error]           Bug$X$1$$anonfun$qux$1.this."$outer " // private[this] val $outer: net.tqft.toolkit.algebra.Bug$X$1, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
[error]           "$outer" // $outer: net.tqft.toolkit.algebra.Bug$X$1, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
[error]         )
[error]       )
[error]       Apply( // def <init>(): scala.runtime.AbstractFunction1$mcVL$sp in class AbstractFunction1$mcVL$sp, tree.tpe=scala.runtime.AbstractFunction1$mcVL$sp
[error]         Bug$X$1$$anonfun$qux$1.super."<init>" // def <init>(): scala.runtime.AbstractFunction1$mcVL$sp in class AbstractFunction1$mcVL$sp, tree.tpe=()scala.runtime.AbstractFunction1$mcVL$sp
[error]         Nil
[error]       )
[error]       ()
[error]     )
[error]   )
[error] )
[error] 
[error] == Expanded type of tree ==
[error] 
[error] TypeRef(
[error]   TypeSymbol(
[error]     abstract trait IndexedSeq extends Seq with IndexedSeq with GenericTraversableTemplate with IndexedSeqLike
[error]     
[error]   )
[error] )
[error] 
[error] uncaught exception during compilation: scala.reflect.internal.FatalError
[error] {file:/Users/scott/projects/toolkit/}toolkit-algebra/compile:compile: scala.reflect.internal.FatalError: 
[error]      while compiling: /Users/scott/projects/toolkit/algebra/src/main/scala/net/tqft/toolkit/algebra/Bug.scala
[error]         during phase: global=mixin, atPhase=cleanup
[error]      library version: version 2.10.0-M6
[error]     compiler version: version 2.10.0-M6
[error]   reconstructed args: -d /Users/scott/projects/toolkit/algebra/target/scala-2.10.0-M6/classes -classpath /Users/scott/projects/toolkit/algebra/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/base/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/arithmetic/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/functions/target/scala-2.10.0-M6/classes:/Users/scott/projects/toolkit/collections/target/scala-2.10.0-M6/classes:/Users/scott/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar:/Users/scott/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.6.1.jar:/Users/scott/.ivy2/cache/log4j/log4j/bundles/log4j-1.2.16.jar:/Users/scott/.ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar:/Users/scott/.ivy2/cache/com.google.guava/guava/jars/guava-12.0.jar:/Users/scott/.ivy2/cache/com.google.code.findbugs/jsr305/jars/jsr305-1.3.9.jar:/Users/scott/.ivy2/cache/org.apache.commons/commons-math/jars/commons-math-2.2.jar:/Users/scott/.ivy2/cache/org.apfloat/apfloat/jars/apfloat-1.6.3.jar -bootclasspath /Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jsfd.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/ui.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/laf.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/sunrsasign.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jsse.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/jce.jar:/Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Classes/charsets.jar:/Users/scott/.sbt/boot/scala-2.10.0-M6/lib/scala-library.jar
[error] 
[error]   last tree to typer: Ident(positions$1)
[error]               symbol: value positions$1 (flags: <param> <synthetic> <triedcooking>)
[error]    symbol definition: positions$1: scala.collection.immutable.IndexedSeq
[error]                  tpe: scala.collection.immutable.IndexedSeq
[error]        symbol owners: value positions$1 -> constructor Permutations$$anonfun$preserving$1 -> anonymous class Permutations$$anonfun$preserving$1 -> package permutations
[error]       context owners: anonymous class Bug$X$1$$anonfun$qux$1 -> package algebra
[error] 
[error] == Enclosing template or block ==
[error] 
[error] Template( // val <local $anonfun>: <notype>, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
[error]   "scala.runtime.AbstractFunction1$mcVL$sp", "scala.Serializable" // parents
[error]   ValDef(
[error]     private
[error]     "_"
[error]     <tpt>
[error]     <empty>
[error]   )
[error]   // 3 statements
[error]   DefDef( // final def apply(x$1: Object): Unit
[error]     <method> final <triedcooking>
[error]     "apply"
[error]     []
[error]     // 1 parameter list
[error]     ValDef( // i: Object
[error]       <param>
[error]       "i"
[error]       <tpt> // tree.tpe=Object
[error]       <empty>
[error]     )
[error]     <tpt> // tree.tpe=Unit
[error]     Apply( // def foo(evidence$1: scala.math.Ordered): Unit in object Bug, tree.tpe=Unit
[error]       Bug.this."foo" // def foo(evidence$1: scala.math.Ordered): Unit in object Bug, tree.tpe=(evidence$1: scala.math.Ordered)Unit
[error]       Bug$X$1$$anonfun$qux$1.this."$outer "."evidence$2$1" // val evidence$2$1: scala.math.Ordered in class Bug$X$1$class, tree.tpe=scala.math.Ordered
[error]     )
[error]   )
[error]   DefDef( // final def apply(v1: Object): Object
[error]     <method> final <bridge>
[error]     "apply"
[error]     []
[error]     // 1 parameter list
[error]     ValDef( // v1: Object
[error]       <param> <triedcooking>
[error]       "v1"
[error]       <tpt> // tree.tpe=Object
[error]       <empty>
[error]     )
[error]     <tpt> // tree.tpe=Object
[error]     Block( // tree.tpe=scala.runtime.BoxedUnit
[error]       Apply( // final def apply(x$1: Object): Unit, tree.tpe=Unit
[error]         Bug$X$1$$anonfun$qux$1.this."apply" // final def apply(x$1: Object): Unit, tree.tpe=(x$1: Object)Unit
[error]         "v1" // v1: Object, tree.tpe=Object
[error]       )
[error]       "scala"."runtime"."BoxedUnit"."UNIT" // final val UNIT: scala.runtime.BoxedUnit in object BoxedUnit, tree.tpe=scala.runtime.BoxedUnit
[error]     )
[error]   )
[error]   DefDef( // def <init>(arg$outer: net.tqft.toolkit.algebra.Bug$X$1): net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
[error]     <method> <triedcooking>
[error]     "<init>"
[error]     []
[error]     // 1 parameter list
[error]     ValDef( // $outer: net.tqft.toolkit.algebra.Bug$X$1
[error]       <param> <triedcooking>
[error]       "$outer"
[error]       <tpt> // tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
[error]       <empty>
[error]     )
[error]     <tpt> // tree.tpe=net.tqft.toolkit.algebra.Bug$X$1$$anonfun$qux$1
[error]     Block( // tree.tpe=Unit
[error]       // 2 statements
[error]       If( // tree.tpe=Unit
[error]         Apply( // final def eq(x$1: Object): Boolean in class Object, tree.tpe=Boolean
[error]           "$outer"."eq" // final def eq(x$1: Object): Boolean in class Object, tree.tpe=(x$1: Object)Boolean
[error]           null
[error]         )
[error]         Throw( // tree.tpe=Nothing
[error]           Apply( // def <init>(): NullPointerException in class NullPointerException, tree.tpe=NullPointerException
[error]             new NullPointerException."<init>" // def <init>(): NullPointerException in class NullPointerException, tree.tpe=()NullPointerException
[error]             Nil
[error]           )
[error]         )
[error]         Assign( // tree.tpe=Unit
[error]           Bug$X$1$$anonfun$qux$1.this."$outer " // private[this] val $outer: net.tqft.toolkit.algebra.Bug$X$1, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
[error]           "$outer" // $outer: net.tqft.toolkit.algebra.Bug$X$1, tree.tpe=net.tqft.toolkit.algebra.Bug$X$1
[error]         )
[error]       )
[error]       Apply( // def <init>(): scala.runtime.AbstractFunction1$mcVL$sp in class AbstractFunction1$mcVL$sp, tree.tpe=scala.runtime.AbstractFunction1$mcVL$sp
[error]         Bug$X$1$$anonfun$qux$1.super."<init>" // def <init>(): scala.runtime.AbstractFunction1$mcVL$sp in class AbstractFunction1$mcVL$sp, tree.tpe=()scala.runtime.AbstractFunction1$mcVL$sp
[error]         Nil
[error]       )
[error]       ()
[error]     )
[error]   )
[error] )
[error] 
[error] == Expanded type of tree ==
[error] 
[error] TypeRef(
[error]   TypeSymbol(
[error]     abstract trait IndexedSeq extends Seq with IndexedSeq with GenericTraversableTemplate with IndexedSeqLike
[error]     
[error]   )
[error] )
[error] 
[error] No getter for value evidence$2$1 in trait Bug$X$1
@scabug
Copy link
Author

scabug commented Aug 14, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6231?orig=1
Reporter: Scott Morrison (scott)
Affected Versions: 2.9.2, 2.10.0-M6

@scabug
Copy link
Author

scabug commented Aug 14, 2012

@retronym said:
Cut down:

object Bug {
  def bar(ev: Any) {
    trait X {
      def qux = { () => ev }
    }
  }
}
== Expanded type of tree ==

TypeRef(TypeSymbol(class Object extends ))

No getter for value ev$1 in trait Bug$X$1
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:46)
	at scala.tools.nsc.Global.abort(Global.scala:249)
	at scala.tools.nsc.transform.Mixin$MixinTransformer$$anonfun$14.apply(Mixin.scala:1220)
	at scala.tools.nsc.transform.Mixin$MixinTransformer$$anonfun$14.apply(Mixin.scala:1220)
	at scala.reflect.internal.Symbols$Symbol.orElse(Symbols.scala:2080)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.scala$tools$nsc$transform$Mixin$MixinTransformer$$postTransform(Mixin.scala:1220)
	at scala.tools.nsc.transform.Mixin$MixinTransformer$$anonfun$transform$1.apply(Mixin.scala:1248)
	at scala.tools.nsc.transform.Mixin$MixinTransformer$$anonfun$transform$1.apply(Mixin.scala:1248)
	at scala.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:195)
	at scala.reflect.internal.SymbolTable.exitingPhase(SymbolTable.scala:199)
	at scala.tools.nsc.Global.exitingMixin(Global.scala:1058)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:1248)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:472)
	at scala.reflect.internal.Trees$$anonfun$itransform$5.apply(Trees.scala:1181)
	at scala.reflect.internal.Trees$$anonfun$itransform$5.apply(Trees.scala:1179)

@scabug
Copy link
Author

scabug commented Jan 20, 2013

@retronym said:

        case Select(qual, name) if sym.owner.isImplClass && !isStaticOnly(sym) =>
          assert(!sym.isMethod, "no method allowed here: %s%s %s".format(sym, sym.isImplOnly, flagsToString(sym.flags)))
          // refer to fields in some implementation class via an abstract
          // getter in the interface.
          val iface  = toInterface(sym.owner.tpe).typeSymbol
          val getter = sym getter iface orElse abort("No getter for " + sym + " in " + iface)

          typedPos(tree.pos)((qual DOT getter)())

sym.owner.tpe (the trait implementation class) contains the a member, ev$1, but this isn't reflected in the trait interface.

This comment seems relevant:

    /** If this symbol is an implementation class, its interface, otherwise the symbol itself
     *  The method follows two strategies to determine the interface.
     *   - during or after erasure, it takes the last parent of the implementation class
     *     (which is always the interface, by convention)
     *   - before erasure, it looks up the interface name in the scope of the owner of the class.
     *     This only works for implementation classes owned by other classes or traits.
     *     !!! Why?
     */
    def toInterface: Symbol = this

@scabug
Copy link
Author

scabug commented Jan 20, 2013

@gkossakowski said:
Jason, are you looking more into this ticket? Do you want it to be reassigned to you?

@scabug
Copy link
Author

scabug commented Jan 20, 2013

@retronym said:
Yep, I'll take a look.

@scabug
Copy link
Author

scabug commented Jan 21, 2013

@retronym said:
A fix is quite involved, for now I've just issued an implementation restriction when we get into this situation, rather than crashing.

scala/scala#1946

@scabug scabug closed this as completed Jan 26, 2013
@scabug
Copy link
Author

scabug commented Mar 15, 2013

@paulp said:
Amassing yet more evidence that I've basically wasted my life, this is a duplicate of #2897. Here's the reproduction from that ticket, which I'll close because higher numbers are better.

  def f1(t: String) = {
    trait T {
      def xs = Nil map (_ => t)
    }
    ()
  }

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

2 participants