I have a class in Scala, which is currently constructed in the standard manner:
class Test( int : Int )
{
override def toString() = "Test: %d".format( int )
}
However, I'd like to move over to indirect construction via a companion object. As the library I'm modifying is used by others, I don't want to make the constructor private straight away. Instead, I'd like to deprecate it and then come back and make it private once people have had a chance to change their usage. So I modified my code like this:
object Test
{
def apply( int : Int ) = new Test( int )
}
@deprecated( "Don't construct directly - use companion constructor", "09/04/13" )
class Test( int : Int )
{
override def toString() = "Test: %d".format( int )
}
However, this deprecates the whole class.
scala> Test( 4 )
<console>:10: warning: class Test in package foo is deprecated: Don't construct directly - use companion constructor
val res0 =
^
res0: com.foo.Test = Test: 4
Does anyone know if Scala supports deprecation of constructors, and if so how it is done?