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

Use ArraySeq.untagged instead of ClassTag[Nothing] #3324

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

travisbrown
Copy link
Contributor

Another fairly trivial change that fixes Dotty breakage and avoids some arguably weird behavior on Scala 2. The code this touches has never been released and in any case these changes shouldn't affect the behavior of these implementations.

On Scala 2 you can write something like this:

scala> import scala.collection.immutable.ArraySeq
import scala.collection.immutable.ArraySeq

scala> def empty[A]: ArraySeq[A] = ArraySeq.empty
empty: [A]=> scala.collection.immutable.ArraySeq[A]

But it doesn't work on Dotty:

scala> import scala.collection.immutable.ArraySeq                                                                                                                                                                                            

scala> def empty[A]: ArraySeq[A] = ArraySeq.empty
1 |def empty[A]: ArraySeq[A] = ArraySeq.empty
  |                                          ^
  |                                          No ClassTag available for A

Which is similar to what happens on Scala 2 if you don't let the type parameter get inferred:

scala> def empty[A]: ArraySeq[A] = ArraySeq.empty[A]
                                                 ^
       error: No ClassTag available for A

I think what's happening on Scala 2 is that Nothing is inferred and this implicit ClassTag[Nothing] is plugged in:

scala> implicitly[reflect.ClassTag[Nothing]]
res0: scala.reflect.ClassTag[Nothing] = Nothing

Dotty's scala.reflect doesn't provide this instance:

scala> implicitly[reflect.ClassTag[Nothing]]                                                                                                                                                                                                 
1 |implicitly[reflect.ClassTag[Nothing]]
  |                                     ^
  |                                     No ClassTag available for Nothing

Changes to these two lines fixes the issue on Dotty by using the untagged factory, which uses a ClassTag[Any] behind the scenes.

@codecov-io
Copy link

codecov-io commented Feb 26, 2020

Codecov Report

Merging #3324 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3324   +/-   ##
=======================================
  Coverage   93.31%   93.31%           
=======================================
  Files         378      378           
  Lines        7684     7684           
  Branches      233      233           
=======================================
  Hits         7170     7170           
  Misses        514      514
Flag Coverage Δ
#scala_version_212 93.38% <ø> (ø) ⬆️
#scala_version_213 93.09% <100%> (ø) ⬆️
Impacted Files Coverage Δ
...src/main/scala-2.13+/cats/instances/arraySeq.scala 100% <100%> (ø) ⬆️

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 2e12f4d...13fd9e5. Read the comment docs.

@fthomas fthomas merged commit 2573961 into typelevel:master Feb 26, 2020
@travisbrown travisbrown added this to the 2.2.0-M1 milestone Feb 26, 2020
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.

4 participants