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

Mark match that is unchecked by Scala 2 as unchecked #3190

Merged
merged 1 commit into from
Dec 9, 2019

Conversation

travisbrown
Copy link
Contributor

The Dotty exhaustivity checker is both smarter and more demanding than Scala 2's, and this is a case where it warns while Scala 2 just silently ignores the fact that it can't prove exhaustivity (it's the only case like this in cats-core).

It would be possible to make the match exhaustive in a way that both compilers would accept by writing something like this:

  as match {
    case h ==: t   => f(h, Eval.defer(loop(t)))
    case _ => lb
  }

…but that results in an extra ArrayBuffer instantiation in the empty case. Adding @unchecked seems to me like a reasonable fix, since it just flags what the Scala 2 compiler is already doing.

@codecov-io
Copy link

codecov-io commented Dec 4, 2019

Codecov Report

Merging #3190 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3190   +/-   ##
=======================================
  Coverage   92.99%   92.99%           
=======================================
  Files         376      376           
  Lines        7382     7382           
  Branches      195      201    +6     
=======================================
  Hits         6865     6865           
  Misses        517      517
Flag Coverage Δ
#scala_version_212 93.32% <ø> (+0.01%) ⬆️
#scala_version_213 90.55% <ø> (-0.03%) ⬇️
Impacted Files Coverage Δ
core/src/main/scala/cats/data/Chain.scala 98.43% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b3bc539...507ca02. Read the comment docs.

@dwijnand
Copy link
Contributor

dwijnand commented Dec 4, 2019

Adding @unchecked seems to me like a reasonable fix, since it just flags what the Scala 2 compiler is already doing.

True, but it's also big and loses the value Dotty is (... finally! IMO) adding, there.

but that results in an extra ArrayBuffer instantiation in the empty case

It's a touch of feature creep, but maybe uncons and initLast should fast-track on isEmpty? It would drop that cost.

@kailuowang kailuowang merged commit f81ac6f into typelevel:master Dec 9, 2019
@travisbrown travisbrown added this to the 2.1.0-RC3 milestone Dec 10, 2019
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.

5 participants