Skip to content

Warning about open classes doesn't work in Scala 3.1.0 #13946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trackiss opened this issue Nov 14, 2021 · 2 comments · Fixed by #14079
Closed

Warning about open classes doesn't work in Scala 3.1.0 #13946

trackiss opened this issue Nov 14, 2021 · 2 comments · Fixed by #14079
Labels
itype:bug regression This worked in a previous version but doesn't anymore

Comments

@trackiss
Copy link

trackiss commented Nov 14, 2021

Compiler version

3.1.0

Minimized code

// in Printer.scala
class Printer:
  def print(s: String): Unit = println(s)
// in BadPrinter.scala
class BadPrinter extends Printer:
  override def print(s: String): Unit = println("Bad!!!")

and enabled -source future flag.
Of course, -language.adHocExtensions flag has been disabled, and it hasn't imported scala.language.adHocExtensions in these source files.

Output

It compiles successfully and no warning is output.

Expectation

The warning should be output because the open modifier hasn't been added.
On the other hand, the warning is output successfully in Scala 3.0.2.

@trackiss trackiss changed the title Warning about Open classes doesn't work in Scala 3.1.0 Warning about Open classes doesn't work in Scala 3.1.0 Nov 14, 2021
@trackiss trackiss changed the title Warning about Open classes doesn't work in Scala 3.1.0 Warning about open classes doesn't work in Scala 3.1.0 Nov 14, 2021
@KacperFKorban KacperFKorban added the regression This worked in a previous version but doesn't anymore label Nov 14, 2021
@odersky
Copy link
Contributor

odersky commented Dec 9, 2021

I could not reproduce that on master. Maybe the -source future did not apply correctly? I made a regression test to make sure we do not regress in the future.

odersky added a commit to dotty-staging/dotty that referenced this issue Dec 9, 2021
@som-snytt
Copy link
Contributor

without consulting the master,

Using scala version 3.1.0 in this shell.
➜  i13946 scalac -source future *la
there were 1 feature warning(s); re-run with -feature for details
➜  i13946 scalac -feature -source future *la
-- Feature Warning: badprinter.scala:2:25 -------------------------------------------------------------------------------------------------------
2 |class BadPrinter extends Printer:
  |                         ^^^^^^^
  |                         Unless class Printer 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

Per the previous comment, the real bug is how did the OP see their unexpected output? For example, -Wconf? under the aegis of "things should just work".

"Use the flag, Luke."

olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants