You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@main defTest=valit=4242Lmatchcase `it` => println("pass")
case _ => println("fail")
Output
sbt:reach> run
[info] compiling 1Scala source to /tmp/reach/target/scala-3.1.2-RC1/classes ...
[warn] -- [E030] MatchcaseUnreachableWarning:/tmp/reach/reach.scala:4:9-----------
[warn] 4|case `it` => println("pass")
[warn] | ^^^^
[warn] |Unreachablecase
[warn] one warning found
[info] done compiling
[info] running Test
pass
This issue came up while updating fs2 in the community build in #14395, where -Xfatal-warnings is in use. Can reproduce in fs2 like so:
$ git clone https://github.com/typelevel/fs2.git && cd fs2
$ git rev-parse HEAD
cd280871b516243d120bcd16090f7cb51daddb27
$ sbt "++3.1.2-RC1 coreJVM/compile"
[info] welcome to sbt 1.6.1 (AdoptOpenJDK Java 1.8.0_292)
[info] loading global plugins from /home/tgrigg/.sbt/1.0/plugins
[info] loading settings for project fs2-build from plugins.sbt ...
[info] loading project definition from /tmp/fs2/project
[info] loading settings for project root from build.sbt ...
[info] resolving key references (16343 settings) ...
[info] set current project to root (in build file:/tmp/fs2/)
[info] Setting Scala version to 3.1.2-RC1 on 16 projects.
[info] Reapplying settings...
[info] set current project to root (in build file:/tmp/fs2/)
[info] compiling 37 Scala sources to /tmp/fs2/core/jvm/target/scala-3.1.2-RC1/classes ...
[warn] -- [E030] Match case Unreachable Warning: /tmp/fs2/core/shared/src/main/scala/fs2/Stream.scala:2116:21
[warn] 2116 | case `concurrency` => channel.close *> end.complete(()).void
[warn] | ^^^^^^^^^^^^^
[warn] | Unreachable case
[warn] one warning found
#13290 fixed the case 42 version of this but the fix needs to be broadened to kick in here too.
Currently Space calls provablyDisjoint, and then the types get widened to Int and Long inside there, and then are rightly considered disjoint, and we're not free to change the behavior of provablyDisjoint, since it's used elsewhere.
Maybe we just need to modify adaptType again (it's used by isSubtype which is used by intersect — all of these methods are inside Space.scala so we're free to modify them). (In #13290 we added convertConstantType.)
But we have to be careful about changing isSubType because it's also used for other purposes within the matcher. We actually already wrote some wip code that does some widening and that fixes the test case, but then breaks a ton of other stuff. For example if we have case 0 => ..., for reachability purposes we definitely can't allow that 0 to be widened to Int — we didn't cover Int, we only covered 0: Int.
Also looking into an alternate solution path where we leave isSubType alone and alter intersectUnrelatedAtomicTypes not to always believe provablyDisjoint's false result if both types being intersected are numeric.
Compiler version
3.1.2-RC1, 3.1.3-RC1-bin-20220201-ef25672-NIGHTLY
Minimized code
Output
This issue came up while updating fs2 in the community build in #14395, where -Xfatal-warnings is in use. Can reproduce in fs2 like so:
where the relevant code is:
Note that here the type of
concurrency
isInt
andsemaphore.available
isF2[Long]
.Works as expected on 3.1.1 and earlier
Expectation
No warning.
The text was updated successfully, but these errors were encountered: