Here in May, 2020, I was just experimenting with Dotty 0.24 (Scala 3), and I just noticed that the Dotty compiler (dotc) does not have a “strict” flag that’s referred to in the documentation. Instead, when working with open classes, I was able to get the compiler error/warning I was looking for by adding the -source 3.1 flag, as shown in these two examples:
$ dotc -source 3.1 OpenClass* there were 1 feature warning(s); re-run with -feature for details $ dotc -source 3.1 -feature OpenClass* -- Feature Warning: OpenClass2.scala:2:23 -------------------------------------- 2 |class Employee extends Person | ^^^^^^ |Unless class Person is declared 'open', its extension in a separate file should be enabled |by adding the import clause 'import scala.language.adhocExtensions' |or by setting the compiler option -language:adhocExtensions. |See the Scala docs for value scala.language.adhocExtensions for a discussion |why the feature should be explicitly enabled. 1 warning found
In my case I put a Person class in one file and an Employee class that extends Person in another file, and I didn’t expect them to compile without a warning because of what I read in the docs. But then I read that you’ll only get the warning message if the -strict flag is used with dotc, and then I further discovered there is no strict flag, but you can use the command line arguments shown with dotc to see the warning message.
Note: The docs on this page currently state, “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 -strict. It will be produced by default from Scala 3.1 on.”