Skip to content

sealed and final classes can be extended using SAM #5888

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
guyde2011 opened this issue Feb 10, 2019 · 1 comment
Closed

sealed and final classes can be extended using SAM #5888

guyde2011 opened this issue Feb 10, 2019 · 1 comment

Comments

@guyde2011
Copy link

This is pretty straight forward.

For example:

  val x: String <:< Int = _.toInt
  println(x("3") - 2)

Compiles and prints 1.

@allanrenucci
Copy link
Contributor

Same for final abstract class:

scala> abstract final class Foo { def f(x: Int): Int }
// defined class Foo

scala> val foo: Foo = x => x
val foo: Foo = anon$1@42fc4ac4

@allanrenucci allanrenucci changed the title Sealed classes can be extended elsewhere using SAM sealed and final classes can be extended using SAM Feb 10, 2019
odersky added a commit that referenced this issue Feb 15, 2019
Fix #5888: Disallow SAM type creation of final and sealed classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants