- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Some questions about the different deprecations around case classes and one weirdness
Thu, 2011-03-24, 18:13
Hi everyone,
I asked some of the questions concerning case classes already on IRC,
but I'll post some things here again...
Compare the message:
==========case-to-case inheritance==========
scala> case class Foo()
defined class Foo
scala> case class Bar() extends Foo()
:9: warning: case class `class Bar' has case ancestor `class
Foo'. Case-to-case inheritance has potentially dangerous bugs which are
unlikely to be fixed. You are strongly encouraged to instead use
extractors to pattern match on non-leaf nodes.
case class Bar() extends Foo()
^
defined class Bar
==========case-to-case inheritance==========
with:
==========scala.dbc deprecation==========
scala> scala.dbc.exception.
IncompatibleSchema UnsupportedFeature
scala> new scala.dbc.exception.UnsupportedFeature("")
:7: warning: class UnsupportedFeature in package exception is
deprecated: scala.dbc will be removed after version 2.9. Use an active
sql library such as scalaquery instead.
val res12 =
^
:8: warning: class UnsupportedFeature in package exception is
deprecated: scala.dbc will be removed after version 2.9. Use an active
sql library such as scalaquery instead.
new scala.dbc.exception.UnsupportedFeature("")
^
:6: warning: class UnsupportedFeature in package exception is
deprecated: scala.dbc will be removed after version 2.9. Use an active
sql library such as scalaquery instead.
lazy val $result = {
^
res12: scala.dbc.exception.UnsupportedFeature =
scala.dbc.exception.UnsupportedFeature
==========scala.dbc deprecation==========
The message about case-to-case inheritance reads more like "it's a bad
idea, and it's buggy" although it is scheduled for removal after 2.9,
just like scala.dbc. Why is the warning not more explicit about what
will happen after 2.9?
Additionally, will "case classes without a parameter list" also be
removed after 2.9? Or is it deprecated for a shorter time only?
==========case classes without a parameter list==========
scala> case class Boo
:1: warning: case classes without a parameter list have been
deprecated;
use either case objects or case classes with `()' as parameter list.
case class Boo
^
:7: warning: case classes without a parameter list have been
deprecated;
use either case objects or case classes with `()' as parameter list.
case class Boo
^
defined class Boo
==========case classes without a parameter list==========
One last thing:
==========case classes without copy method==========
scala> case class Baz()
defined class Baz
scala> val baz = Baz()
baz: Baz = Baz()
scala> baz.copy()
:11: error: value copy is not a member of Baz
baz.copy()
^
==========case classes without copy method==========
Why is the (less than useful) copy method missing here?
I checked §5.3.2, but it doesn't mention any exceptions except a copy
method already existing, so why does the compiler forget to create the
copy method here?
Thanks and Bye!
Simon