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

Wrong type erasure warning with Scala 2.10.0-M2 and -Yvirtpatmat

    Details

      Description

      When switching from Scala 2.9.1 to 2.10.0-M2 with virtpatmatch enabled, a wrong type erasure warning is emitted in this class: https://github.com/Sciss/ScalaAudioFile/blob/scala-2.10.0-M2-test/src/main/scala/de/sciss/synth/io/AudioFile.scala . The code is as follows:

            val sf   = spec.sampleFormat
            ...
            sf.bidiFactory match {
               case Some( bbf ) =>
                  val bb   = bbf( ch, ch, buf, spec.numChannels )
                  new BidiFileImpl( f, raf, afh, bb )
               case None        =>
                  val bw = sf.writerFactory.map( _.apply( ch, buf, spec.numChannels )).getOrElse( noEncoder( sf ))
                  new WritableFileImpl( f, raf, afh, bw )
            }
      

      Method bidiFactory has return type Option[ BufferBidiFactory ], so there is no further generics involved other than having the option. Without virtpatmat it compiles fine, with virtpatmat the following warning is emitted:

      [warn] /Users/hhrutz/Documents/devel/ScalaAudioFile/src/main/scala/de/sciss/synth/io/AudioFile.scala:188: non variable type-argument de.sciss.synth.io.BufferBidiFactory in type Some[de.sciss.synth.io.BufferBidiFactory] is unchecked since it is eliminated by erasure
      [warn]          case Some( bbf ) =>
      [warn]                   ^
      

      Clearly the extractor should work without any erasure warnings. To reproduce clone the following project/branch https://github.com/Sciss/ScalaAudioFile/tree/scala-2.10.0-M2-test and run `sbt compile` (use the nightly sbt from http://repo.typesafe.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/0.11.3-20120130-052105/ )

        Activity

        Sciss created issue -
        Hide
        Seth Tisue added a comment - - edited

        this is reproducible on current master with very simple code:

        ~/scala % dists/latest/bin/scala -unchecked
        Welcome to Scala version 2.10.0-20120424-191812-996f96fb3f
        
        scala> Option(3) match { case Some(n) => n; case None => 0 }
        <console>:8: warning: non variable type-argument Int in type Some[Int] is unchecked since it is eliminated by erasure
                      Option(3) match { case Some(n) => n; case None => 0 }
                                                 ^
        res0: Int = 3
        
        Show
        Seth Tisue added a comment - - edited this is reproducible on current master with very simple code: ~/scala % dists/latest/bin/scala -unchecked Welcome to Scala version 2.10.0-20120424-191812-996f96fb3f scala> Option(3) match { case Some(n) => n; case None => 0 } <console>:8: warning: non variable type-argument Int in type Some[Int] is unchecked since it is eliminated by erasure Option(3) match { case Some(n) => n; case None => 0 } ^ res0: Int = 3
        Hide
        Seth Tisue added a comment -

        perhaps related: SI-5503

        Show
        Seth Tisue added a comment - perhaps related: SI-5503
        Hide
        Adriaan Moors added a comment -

        fixed by moving patmat to its own phase (the spurious warnings arose from emitted isInstanceOf's, where the unchecked bits are not relied upon)

        Show
        Adriaan Moors added a comment - fixed by moving patmat to its own phase (the spurious warnings arose from emitted isInstanceOf's, where the unchecked bits are not relied upon)
        Lukas Rytz made changes -
        Field Original Value New Value
        Labels erasure pattern-matching warning erasure warning
        Hide
        Hubert Plociniczak added a comment -

        Test case in eae60ae

        Show
        Hubert Plociniczak added a comment - Test case in eae60ae
        Hubert Plociniczak made changes -
        Status Open [ 1 ] CLOSED [ 6 ]
        Resolution Fixed [ 1 ]
        Hide
        Hubert Plociniczak added a comment -

        Adriaan was quicker: e9ed9d4280246fec.

        Show
        Hubert Plociniczak added a comment - Adriaan was quicker: e9ed9d4280246fec.
        Adriaan Moors made changes -
        Fix Version/s Scala 2.10.0-M3 [ 10901 ]

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            Sciss
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development