Hi all,
Am new to Scala and am studying open class
am having two class in two files
package test
class Promotion {
def promotionDiscountFactor: Int = 2
}
package test
class StudentPromotion extends Promotion {
override def promotionDiscountFactor: Int = 4
}
when am extending the class with another file it not gives me waring when am
compile in cmd prompt like:scalac -feature Promotion.scala StudentPromotion.scala
it is compiling successfully rather than gives me warning.
please help me to resolve this
Despite what the docs say,
open
is a new modifier in Scala 3. To allow cross compilation between Scala 2.13 and Scala 3.0 without warnings, the feature warning for ad-hoc extensions is produced only under -source future
. It will be produced by default from Scala 3.1 on.
even on Scala 3.3.1, the warning is only produced when -source future
is present.
I created a PR to update the docs.
2 Likes
Thanks @adamdabrowski yes documentation is updated can you say how to use this -source future in cmd.
scalac -feature -source future Promotion.scala StudentPromotion.scala