Skip to content

No murmur from pattern match of singleton type of Any #14835

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
som-snytt opened this issue Apr 3, 2022 · 1 comment
Closed

No murmur from pattern match of singleton type of Any #14835

som-snytt opened this issue Apr 3, 2022 · 1 comment

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.1.3-RC1

Minimized code

class C[A <: AnyRef] { val a: A = null.asInstanceOf[A] ; def f(x: A) = x match { case _: a.type => 42 } }
class D[A] { val a: A = null.asInstanceOf[A] ; def f(x: A) = x match { case _: a.type => 42 } }

Output

scala> class C[A] { val a: A = null.asInstanceOf[A] ; def f(x: A) = x match { case _: a.type => 42 } }
// defined class C

scala> class C[A <: AnyRef] { val a: A = null.asInstanceOf[A] ; def f(x: A) = x match { case _: a.type => 42 } }
// defined class C

Expectation

scala 2.13.8> class C[A] { val a: A = null.asInstanceOf[A] ; def f(x: A) = x match { case _: a.type => 42 } }
                                                                                              ^
              warning: abstract type pattern A (the underlying of C.this.a.type) is unchecked since it is eliminated by erasure
class C

Some sort of messaging that my singleton type pattern is not kosher and will not be checked with eq.

With the upper bound, eq is used as expected. That is the same behavior as Scala 2, which murmurs about it.

Forward port of scala/bug#12569

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 3, 2022
@KacperFKorban KacperFKorban added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 4, 2022
@som-snytt
Copy link
Contributor Author

Duplicates #9359 and related

@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
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