Scala Constructor Deprecation -
i have class in scala, constructed in standard manner:
class test( int : int ) { override def tostring() = "test: %d".format( int ) }
however, i'd move on indirect construction via companion object. library i'm modifying used others, don't want make constructor private straight away. instead, i'd deprecate , come , make private once people have had chance change usage. modified code 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, deprecates whole class.
scala> test( 4 ) <console>:10: warning: class test in package foo deprecated: don't construct directly - use companion constructor val res0 = ^ res0: com.foo.test = test: 4
does know if scala supports deprecation of constructors, , if how done?
this thread seems describe solution:
object test { def apply( int : int ) = new test( int ) } class test @deprecated( "don't construct directly - use companion constructor", "09/04/13" ) ( int : int ) { override def tostring() = "test: %d".format( int ) }
can't try right though.
Comments
Post a Comment