-
Notifications
You must be signed in to change notification settings - Fork 50
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
Can nature of dependency on scalac-compat be clarified? #793
Comments
Thanks for reporting! I transferred here because the dependency is declared in sbt-typelevel. sbt-typelevel/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala Line 69 in 6f9c6a5
The intention was to express that
Actually, it is a compile-time dependency for all Scala versions. We use it in a variety of ways.
Instead of documentation, we should probably drop |
Hmm yep, good point all are compile time (for consumers) dependency of cats, for those interested org.typelevel.scalaccompat.annotation.uncheckedVariance2 and org.typelevel.scalaccompat.annotation.unused in scala 2.13 are aliases for standard lib annotations, but org.typelevel.scalaccompat.annotation.targetName3 isn't :(. Re rationale, yes I think there is no good semantic built into poms/sbt, Provided isn't strictly the right semantic and more just incidental that it does sort of the right thing, 'provided' as maven intended means something external provides at runtime (https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html), e.g. spark dependencies are 'provided' by a spark runtime. It's actually not super clear to me what's best then 😕. As I see things, most important thing is just that users of cats know 'yes it is expected some times that at compile time you will need dependency on scalac-compat', because really the resolution to compiler error is clear, it's just that finding out /why/ you need to do so isn't at all clear. I think this issue existing more or less resolves that, and I'm happy at least that I know what to do in original context that I found this thing. The issues with that are
Longer term, I guess there doesn't feel like a huge amount of options, you can imagine either an sbt plugin associated with cats that does the work of managing this scalac-compat dependency for you (i.e. like what TypelevelSettingsPlugin.scala is doing, but probably solely adding scalac-compat-annotation dependency). Or it would be nice if something that gets published could have some metadata in it, that sbt could then read and natively know to do compile-only stuff, I'm mostly familar with Gradle, and there they actually made their whole own alternative to poms as they were so upset with the limitations... https://github.com/gradle/gradle/blob/master/platforms/documentation/docs/src/docs/design/gradle-module-metadata-latest-specification.md |
I notice that as of 2.13 (of cats-core), due to typelevel/cats@c442521#diff-7c156dc8732800194b79210cf462828782dcdf1b516cfc26f72afe892f8d279cR53, if you have like
and compile against scala 2.12, you get compilation error
(actually in reality, the context I found this in was more a lot more confusing, scala compiler didn't at all point me to correct line or file causing the issue 😞 ).
Anyway, org.typelevel.scalaccompat.annotation.unused is indeed in scalasignature of MapInstances class, and reading https://github.com/typelevel/scalac-compat/blob/main/annotation/src/main/scala-2.12/org/typelevel/scalaccompat/annotation/unused.scala I guess this is all 'as intended'.
That's all /fine/ and scalac-compat is listed as provided dependency, and if you add it as dependency, OK my code example works.
Questions are
The text was updated successfully, but these errors were encountered: