Skip to content

fix: Fixes infer-any warning on F[_]#11157

Closed
eed3si9n wants to merge 1 commit intoscala:2.13.xfrom
eed3si9n:wip/infer-nothing
Closed

fix: Fixes infer-any warning on F[_]#11157
eed3si9n wants to merge 1 commit intoscala:2.13.xfrom
eed3si9n:wip/infer-nothing

Conversation

@eed3si9n
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n commented Oct 22, 2025

Fixes scala/bug#13128

Problem

infer-any linter warns on F[_] when the function is curried.

Solution

Don't warn when the inference is retractable, which is Nothing.

@scala-jenkins scala-jenkins added this to the 2.13.18 milestone Oct 22, 2025
@lrytz lrytz force-pushed the wip/infer-nothing branch from c89c8ed to 0024ebe Compare October 22, 2025 08:24
**Problem**
infer-any linter warns on F[_] when the function is curried.

**Solution**
Don't warn when the inference is retractable, which is Nothing.
@lrytz
Copy link
Copy Markdown
Member

lrytz commented Oct 23, 2025

Thoughs / observations:

  1. Do we know any real-world examples where Nothing is inferred and the warning seems useful? The two examples I added as test case here are synthetic. Other than that, I only saw examples where the desired warning is about inferring Any. I think the idea of warning for Nothing came from #4401 by symmetry, but there's no example there (or in #11053).

  2. There's an existing warning for inferring Any in 2.13.16, but it doesn't trigger if the expected type is Any:

class Bar
class Test {
  def f[F[_], A](v: F[A]) = v
  implicit def barToList(b: Bar): List[Int] = List(42)
  def t1 = f(new Bar)      // warns in 2.13.16, two warnings in 2.13.17
  def t2: Any = f(new Bar) // no warning in 2.13.16, new 'kind-polymorphic' warning in 2.13.17
}

That's because the Any makes it into the type var bounds, affecting !tvar.constr.hiBounds.exists(t => topTypes.contains(t.typeSymbol)). I think this needs to stay (#9452).

  1. The object retronym test case added in #11053 doesn't actually trigger any warning. None of test1 / test2 (after un-commenting) / test3 lead to inferring Any for F[_]. So inference improved it seems, maybe due to SI-2712.

So I think we should revert the new warning for the Nothing case.

Perhaps also revert it for the Any case? We know a few examples where the warning shows up due to weak inference of Scala 2 (example, example), but it's hard to know how many people this affects and how useful it really is.

@eed3si9n
Copy link
Copy Markdown
Member Author

Yea, the ratio of kind-checking saving the day vs posing issues does not seem great, so I'm supportive of just reverting the whole thing.

@lrytz
Copy link
Copy Markdown
Member

lrytz commented Oct 24, 2025

#11162

@lrytz lrytz closed this Oct 24, 2025
@lrytz lrytz removed the prio:blocker release blocker (used only by core team, only near release time) label Oct 24, 2025
@lrytz lrytz removed this from the 2.13.18 milestone Oct 24, 2025
@eed3si9n eed3si9n deleted the wip/infer-nothing branch October 24, 2025 15:01
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

Successfully merging this pull request may close these issues.

New false positive warning with 2.13.17: a type was inferred to be kind-polymorphic Nothing to conform to F[_]

4 participants