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

Value class error when method signature references class type parameter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.0-M2
    • Component/s: Misc Compiler
    • Labels:
    • Environment:

      $ git describe
      v2.10.0-M2-338-gd9d46a8

      Description

      Compiling

      class Foo[T](val x: Int) extends AnyVal { def xyzzy(t:T) = t } 
      
      object Test {
        new Foo[String](4).xyzzy(null)
      }
      

      causes an assertion failure in the compiler

      error: 
           while compiling:  ok.scala
             current phase:  erasure
           library version:  version 2.10.0-20120320-074449-d9d46a8bbb
          compiler version:  version 2.10.0-20120320-074449-d9d46a8bbb
        reconstructed args:  
      
      uncaught exception during compilation: java.lang.AssertionError
      error: java.lang.AssertionError: assertion failed: 
           while compiling:  ok.scala
             current phase:  refchecks
           library version:  version 2.10.0-20120320-074449-d9d46a8bbb
          compiler version:  version 2.10.0-20120320-074449-d9d46a8bbb
        reconstructed args:  
      
      no extension method found for method xyzzy among Stream(method extension$xyzzy)/Stream(extension$xyzzy, ?)
      	at scala.Predef$.assert(Predef.scala:161)
      	at scala.tools.nsc.Global.assert(Global.scala:176)
      	at scala.tools.nsc.transform.ExtensionMethods$$anonfun$extensionMethod$1.apply(ExtensionMethods.scala:67)
      	at scala.tools.nsc.transform.ExtensionMethods$$anonfun$extensionMethod$1.apply(ExtensionMethods.scala:58)
      	at scala.reflect.internal.SymbolTable.atPhase(SymbolTable.scala:138)
      	at scala.tools.nsc.transform.ExtensionMethods.extensionMethod(ExtensionMethods.scala:58)
      	at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$1.preErase(Erasure.scala:1045)
      	at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$1.transform(Erasure.scala:1100)
              [snip]
      

      It seems to stem from the argument involving the class' type parameter. I think the matches check around the assertion does not consider the two type parameters to match.

        Activity

        Hide
        Geoff Reedy added a comment -

        Guess I should mention here that I've got a pull request open with an apparent fix for this issue (and a test case for it) at https://github.com/scala/scala/pull/302

        Show
        Geoff Reedy added a comment - Guess I should mention here that I've got a pull request open with an apparent fix for this issue (and a test case for it) at https://github.com/scala/scala/pull/302
        Hide
        Martin Odersky added a comment -

        Closed by Geoff's pull request.

        Show
        Martin Odersky added a comment - Closed by Geoff's pull request.

          People

          • Assignee:
            Martin Odersky
            Reporter:
            Geoff Reedy
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development