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

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

Closed
scabug opened this issue Mar 4, 2012 · 6 comments
Closed

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

scabug opened this issue Mar 4, 2012 · 6 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 4, 2012

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/ )

@scabug
Copy link
Author

scabug commented Mar 4, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5542?orig=1
Reporter: @Sciss
Affected Versions: 2.10.0-M2

@scabug
Copy link
Author

scabug commented Apr 24, 2012

@SethTisue said (edited on May 23, 2012 1:45:46 PM UTC):
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

@scabug
Copy link
Author

scabug commented May 1, 2012

@SethTisue said:
perhaps related: #5503

@scabug
Copy link
Author

scabug commented May 2, 2012

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

@scabug
Copy link
Author

scabug commented May 8, 2012

@hubertp said:
Test case in eae60ae

@scabug scabug closed this as completed May 8, 2012
@scabug
Copy link
Author

scabug commented May 8, 2012

@hubertp said:
Adriaan was quicker: e9ed9d4280246fec.

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017
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