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

False positives with -Wself-implicit #11813

Closed
DavidGregory084 opened this issue Nov 27, 2019 · 3 comments · Fixed by scala/scala#8561
Closed

False positives with -Wself-implicit #11813

DavidGregory084 opened this issue Nov 27, 2019 · 3 comments · Fixed by scala/scala#8561

Comments

@DavidGregory084
Copy link

Enabling the -Wself-implicit flag causes spurious warnings when compiling code in the console4cats project.

Affected code: https://github.com/profunktor/console4cats/blob/master/core/src/main/scala/cats/effect/ConsoleError.scala#L33

[error] /home/circleci/repo/core/src/main/scala/cats/effect/ConsoleError.scala:33:56: Implicit resolves to enclosing value catsStdShowForString
[error]   def putError(str: String): F[Unit] = putError[String](str)
[error]                                                        ^
[error] /home/circleci/repo/core/src/main/scala/cats/effect/ConsoleOut.scala:33:56: Implicit resolves to enclosing value catsStdShowForString
[error]   def putStrLn(str: String): F[Unit] = putStrLn[String](str)
[error]                                                        ^
[error] /home/circleci/repo/core/src/main/scala/cats/effect/ConsoleOut.scala:43:52: Implicit resolves to enclosing value catsStdShowForString
[error]   def putStr(str: String): F[Unit] = putStr[String](str)
[error]                                                    ^
[error] three errors found
[error] (console4cats / Compile / compileIncremental) Compilation failed
[error] Total time: 10 s, completed Nov 27, 2019 7:03:39 AM

See profunktor/console4cats#65

@som-snytt
Copy link

Thanks, I'll take a look. In the meantime, maybe change the title of the linked issue to, "Consider not adding -Wself-implicit".

@DavidGregory084
Copy link
Author

Thanks @som-snytt! There are some more examples in these PRs:

http4s/http4s#2997
http4s/blaze#360

@som-snytt
Copy link

This comment in TreeCheckers is relevant:

/* XXX: lots of syms show up here with accessed == NoSymbol. */

There is more explanatory commentary at def accessed on the perils involved.

Also, hasTransOwner is trivially true for NoSymbol, which is the root of all evil, I mean the root of root.

So avoiding the false positive is easy; not sure about possible false negatives.

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

Successfully merging a pull request may close this issue.

3 participants