-
Notifications
You must be signed in to change notification settings - Fork 21
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
Package object extends deprecated under -Xsource:3 not dotty #12886
Comments
I'm doing some due diligence before removing the warning. aaa/Protocols.scalapackage aaa
trait Protocols:
implicit lazy val fooOrdering: Ordering[example.Foo] = new Ordering[example.Foo]:
def compare(a: example.Foo, b: example.Foo): Int = 0
def something = 1 example/package.scalapackage example
object `package` extends aaa.Protocols
case class Foo() demoand the trouble is that the package object doesn't seem to be part of the implicit scope? sbt:foo> console
[info] compiling 3 Scala sources to /private/tmp/foo/target/scala-3.3.0/classes ...
Welcome to Scala 3.3.0 (1.8.0_352, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> List(example.Foo()).sorted
-- [E172] Type Error: ----------------------------------------------------------
1 |List(example.Foo()).sorted
| ^
|No implicit Ordering defined for B..
|I found:
|
| scala.math.Ordering.ordered[B](
| /* missing */summon[scala.math.Ordering.AsComparable[B]])
|
|But no implicit values were found that match type scala.math.Ordering.AsComparable[B]
|
|where: B is a type variable with constraint >: example.Foo
|.
|
|The following import might fix the problem:
|
| import example.fooOrdering
|
1 error found so this demonstrates that:
|
In fact, there is an Adriaan comment on the linked ticket somewhere that suggests the "package prefix" issue was his real concern, not merely inheritance. I'll consider instead having a Scala 2 flag to a) warn about that and b) change the behavior. Possibly, The scratch for the itch would have been scala/scala-dev#446 I forgot that I'd commented there that |
Agree 👍 thanks for summarizing everything. |
Footnote, I tried |
Removed the warning in scala/scala#10573. Seth also suggested to introduce a warning under |
Or, as Lukas counter-suggested, at definition site (when a package object defines an implicit)? I worry that warning at the use site might be too annoying if the implicit in question is coming from a library that the user doesn't control. @som-snytt above when you wrote "warn about that" did you have one or the other approach in mind? |
I think I had the Seth solution in mind. I haven't had coffee yet. The spouse is yelling about something. Oh, I see your question is, is that annoying? if a library defined an implicit in an old-fashioned way. Well, that will break under Scala 3, so the job in Scala 2 is to annoy. |
Reproduction steps
Scala version: 2.13.12
then
Problem
Dotty doesn't give a peep in 3.3.
eed3si9n/scalaxb#606
Notes
The text was updated successfully, but these errors were encountered: