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

TypeTest matching does not seem to work from singleton types #10318

Open
LPTK opened this issue Nov 14, 2020 · 0 comments
Open

TypeTest matching does not seem to work from singleton types #10318

LPTK opened this issue Nov 14, 2020 · 0 comments
Assignees

Comments

@LPTK
Copy link
Contributor

LPTK commented Nov 14, 2020

Minimized code

import scala.reflect.TypeTest

extension [A](self: Any) def being(using TypeTest[self.type, A]) =
  self match { case self: A => Some(self); case _ => None }

Output

def being[A](self: Any)(using reflect.TypeTest[self.type, A]): Option[A]
2 |  self match { case self: A => Some(self); case _ => None }
  |                    ^^^^^^^
  |                    the type test for A cannot be checked at runtime

Expectation

Should compile. The following manual version works:

import scala.reflect.TypeTest

extension [A](self: Any) def being(using test: TypeTest[self.type, A]) =
  test.unapply(self)
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