Skip to content
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

Scala 3 Matchable Trait #102

Open
bpholt opened this issue Jul 13, 2023 · 1 comment
Open

Scala 3 Matchable Trait #102

bpholt opened this issue Jul 13, 2023 · 1 comment

Comments

@bpholt
Copy link

bpholt commented Jul 13, 2023

Given this scala-cli snippet:

//> using scala 3
//> using option -source:future
//> using dep io.monix::newtypes-core:0.2.3

import monix.newtypes.*

type Foo = Foo.Type
object Foo extends NewtypeWrapped[String]

val foo: Foo = Foo("foo")

@main def main(): Unit =
  foo match
    case Foo(x) =>
      println(x)

Since it includes option -source:future, when this is compiled, it warns

$ scala-cli run matchable.scala 
Compiling project (Scala 3.3.0, JVM)
[warn] ./matchable.scala:14:10
[warn] pattern selector should be an instance of Matchable,,
[warn] but it has unmatchable type Foo instead
[warn]     case Foo(x) =>
[warn]          ^^^^^^
Compiled project (Scala 3.3.0, JVM)
foo

Since it works anyway, I think Matchable should probably be added to the Scala 3 sources, but I'm not exactly sure where. Maybe NewEncoding and NewEncodingK should both extend it? Or maybe a new marker trait should be added to NewWrapped that would then extend Matchable on Scala 3?

I'm happy to make a PR once we have a direction.

@bpholt
Copy link
Author

bpholt commented Sep 6, 2023

@alexandru do you have any thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant