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

Using Cons bypasses Option.Get violation #804

Open
Johnnei opened this issue Nov 23, 2023 · 2 comments
Open

Using Cons bypasses Option.Get violation #804

Johnnei opened this issue Nov 23, 2023 · 2 comments

Comments

@Johnnei
Copy link
Contributor

Johnnei commented Nov 23, 2023

val a = 4
val b = 0
val d = scala.util.Try { a / b }.toOption
val list = 42 :: d.get :: Nil

Quite contrived example which I made while testing the gitlab code quality integration. This doesn't flag for using Option.get.

@mccartney
Copy link
Collaborator

Interesting. I am wondering what makes Cons special here:

if (left.tpe.typeSymbol.fullName == "scala.Option")

@saeltz
Copy link
Collaborator

saeltz commented Apr 14, 2024

It even fails on the very simple:

val list = None.get :: Nil

This is a ValDef in the macro, containing a Block tree type with the following content:

List[Nothing] {
  final <synthetic> <artifact> val rassoc$1: Nothing = scala.None.get;
  scala.`package`.Nil.::[Nothing](rassoc$1)
}

I can't find a way to match on the content of the Block. It somehow isn't a Select.

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

3 participants