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

Annotate pattern bindings with refutable patterns #3520

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

fthomas
Copy link
Member

@fthomas fthomas commented Jan 5, 2025

This is in preparation for compiling with Scala 3 and prevents warnings about pattern bindings with refutable patterns like this:

 -- Warning: modules/core/src/test/scala/org/scalasteward/core/update/PruningAlgTest.scala:218:27
 218 |    val Right(repoCache) = decode[RepoCache](
     |                           ^
     |pattern's type Right[io.circe.Error, org.scalasteward.core.repocache.RepoCache] is more specialized than the right hand side expression's type Either[io.circe.Error, org.scalasteward.core.repocache.RepoCache]
     |
     |If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
     |which may result in a MatchError at runtime.
     |This patch can be rewritten automatically under -rewrite -source 3.2-migration.

The changes here we done by the Scala 3 compiler by using the -rewrite -source 3.2-migration options. They are another large chunk of #2065 that have been cherry-picked from that branch.

Relevant documentation: https://docs.scala-lang.org/scala3/reference/changed-features/pattern-bindings.html

This is in preparation for compiling with Scala 3 and prevents warnings
about pattern bindings with refutable patterns like this:
```
 -- Warning: modules/core/src/test/scala/org/scalasteward/core/update/PruningAlgTest.scala:218:27
 218 |    val Right(repoCache) = decode[RepoCache](
     |                           ^
     |pattern's type Right[io.circe.Error, org.scalasteward.core.repocache.RepoCache] is more specialized than the right hand side expression's type Either[io.circe.Error, org.scalasteward.core.repocache.RepoCache]
     |
     |If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
     |which may result in a MatchError at runtime.
     |This patch can be rewritten automatically under -rewrite -source 3.2-migration.
```
The changes here we done by the Scala 3 compiler by using the
`-rewrite -source 3.2-migration` options. They are another large
chunk of #2065 that have been cherry-picked from that branch.

Relevant documentation: https://docs.scala-lang.org/scala3/reference/changed-features/pattern-bindings.html
@fthomas fthomas added this to the 0.32.2 milestone Jan 5, 2025
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.73%. Comparing base (040cef7) to head (1e1bad2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3520   +/-   ##
=======================================
  Coverage   89.73%   89.73%           
=======================================
  Files         171      171           
  Lines        3536     3536           
  Branches      321      321           
=======================================
  Hits         3173     3173           
  Misses        363      363           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fthomas fthomas merged commit a114407 into main Jan 6, 2025
12 checks passed
@exoego exoego deleted the topic/unchecked-patmats branch January 6, 2025 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants