2.13.15 is breaking type inference

My project uses scala 2.13.14, when updating to scala 2.13.15 (just updating the build.sbt with 2.13.15) the compilation now fails. Here is the PR: chore(dependencies): update scala 2.13.14 to 2.13.15 by broij · Pull Request #21 · broij/zarrow · GitHub

The compilation error:

Which fails at this line:

It looks like the type of the expression is now inferred to Any while in 2.13.14 it was inferred correctly. This triggers a compilation failure since I am using the compilation flags -Xfatal-warnings and -Xlint. Explicitly setting the type doesn’t fix the issue.

This is a breaking change. Opening a question here to flag the bug, since apparently the description is not proper to be claimed as a bug report: 2.13.15 is breaking · Issue #13044 · scala/bug · GitHub

Is there a quick fix for this apart from removing the compilation flag?

Since I got Wordle in two, I have time to try out your project, but it’s especially helpful to minimize, to isolate the behavior from the test framework and any macros.

Of course, it’s possible a macro is implicated.

Linking to C.I. output is less helpful than summarizing.

I see from the release notes that

Improve inferred-Any lint (fixing false positives and false negatives) (#9452 by @som-snytt)

so perhaps you’re not seeing a change in inference but an improvement in linting.

For example,

val zArrow: be.broij.ZArrow[String,Any,Nothing,String] = ZArrow.succeed[String, String](((str: String) => prefix.+(str)));

is the same in 2.13.14 and 2.13.15 (as reported by -Vprint:typer) but only warns in 2.13.15.

You can use

val zArrow      = dyingZArrow.catchAllCause(ZArrow.succeed(expected)): @annotation.nowarn

or -Wconf:something to silence the warning. To figure out the something,

-Wconf:any:wv

to see

[error] Applicable -Wconf / @nowarn filters for this warning: msg=<part of the message>, cat=lint-infer-any, site=be.broij.ZArrowSpec.spec.zArrow

e.g.

"-Wconf:cat=lint-infer-any:s",

It always takes me an extra minute to remember how to turn off “colors” in sbt

sbt -no-colors '++ 2.13.14 ; Test / compile' > y

because I go first to the docs, where I can never find it. I always wind up at internet search, which thankfully always returns the result.

Scala 3 is -color:never.

In case anyone wonders why people love their chatGPT.

Thanks for helping. I am rather looking for a solution that doesn’t revolve around ignoring warning or disabling compilation flags.

What I observe is that if I declare:
val dyingZArrow: ZArrow[Any, Any, String, Nothing]
Or if I put any other type beside Nothing as 3rd type parameter (which is what the compiler infers), then it happily compiles.

I don’t understand how this is not a false positive? What is problematic with this expression?

I should have mentioned that @nowarn takes a filter

@nowarn("cat=lint-infer-any")

On the (locked) ticket, I commented about the fully-annotated explicit expression that does not warn. There are type args to both the method and the typeclass.

I would like to understand. Did the heuristic update introduce some regressions or is the expression with inferred types considered unsafe by -Xlint? If unsafe would you mind explaining to the mortals ? :pray: How come -Xlint considers a broader type to be safer (Any >: Nothing and ZArrow[-I, -R, +E, +A] is covariant in E which is the type argument that I need to explicitly set to Any instead of Nothing which is the inferred type)?