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

activate constrainResult fix in 3.4 #19253

Merged

Conversation

bishabosha
Copy link
Member

@bishabosha bishabosha commented Dec 12, 2023

fixes #18174

Release Notes

Type inference has changed for inline methods in 3.4, which can cause a source incompatibility at the call site. The previous behaviour can be recovered in an affected file with

import scala.language.`3.3`

alternatively the definition can changed to transparent inline, but as this is a TASTy breaking change it is not a default recommendation. (Also inline should be preferred when possible over transparent inline for reduced binary size)

@bishabosha bishabosha requested a review from dwijnand December 12, 2023 16:16
@bishabosha bishabosha added this to the 3.4.0 milestone Dec 12, 2023
@bishabosha bishabosha added the needs-minor-release This PR cannot be merged until the next minor release label Dec 12, 2023
@dwijnand dwijnand requested review from julienrf and removed request for dwijnand December 13, 2023 09:18
@dwijnand dwijnand assigned julienrf and unassigned dwijnand Dec 13, 2023
Copy link
Contributor

@julienrf julienrf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@bishabosha bishabosha merged commit 9dce045 into scala:main Dec 13, 2023
19 checks passed
@bishabosha bishabosha deleted the add-feature-check-wild-approx-inline branch December 13, 2023 10:57
@bishabosha bishabosha added the release-notes Should be mentioned in the release notes label Dec 13, 2023
@bishabosha
Copy link
Member Author

@sjrd and @julienrf asking for advice on the release notes clause

@julienrf
Copy link
Contributor

julienrf commented Dec 20, 2023

I am not sure whether the note should belong to the section “Error reporting improvements” or “Changes with compatibility issues”, but here is a first suggestion:

Before 3.4.0, compilation errors were sometimes containing incorrect suggestions. Here is an example taken from the bug report #9685:

  import munit.FunSuite

  class Example extends FunSuite {
    1.asdf
//  ^^^^^^
// value asdf is not a member of Int, but could be made available as an extension method.
//
// The following import might make progress towards fixing the problem:
//
//    import munit.Clue.generate
  }

In this example, the second part of the error message, which suggest adding an import, is incorrect. Adding the suggested import would not help here.

This issue is fixed in Scala 3.4.0. The error message does not anymore suggest irrelevant imports.

However, the fix changed the way the result types of calls to inline methods are inferred, which could cause compilation errors when upgrading to Scala 3.4.0. You can check if your Scala 3.3.x project would compile with the new type inference behavior by adding the compiler option -source future. In case some files of your project do not compile with Scala 3.4.0 anymore, you can switch back to the old behavior by adding import scala.language.`3.3` in the impacted files, or, preferably, fix the issue by adding more explicit types (so that the compiler does not need to infer them), or, in last resort, by making the method transparent inline instead of just inline.

That being said, it seems #18130, which introduces the -source future behavior has not been backported to Scala 3.3, so the -source future trick indicated above might not work. Unless I missed something?

@julienrf julienrf assigned bishabosha and unassigned julienrf Dec 21, 2023
joroKr21 added a commit to joroKr21/kittens that referenced this pull request Mar 8, 2024
joroKr21 added a commit to typelevel/kittens that referenced this pull request Mar 8, 2024
arainko added a commit to arainko/ducktape that referenced this pull request Jul 23, 2024
…la 3.4.+ (#189)

It fixes compilation, and possibly usage for users of the
`Context.current` due to scala/scala3#19253
Issue spotted by Scala 3 Open Community Build -
[logs](https://github.com/VirtusLab/community-build3/actions/runs/10058953806/job/27803320280)
Since 3.4.0 it would fail with: 
```scala
[error] -- [E172] Type Error: /Users/wmazur/projects/community-build3/repo/ducktape/src/main/scala/io/github/arainko/ducktape/internal/Planner.scala:274:32 
[error] 274 |          ctx.reifyPlan[F](plan)
[error]     |                                ^
[error]     |Cannot prove that io.github.arainko.ducktape.internal.Plan[
[error]     |  io.github.arainko.ducktape.internal.Erroneous, ctx.F] =:= io.github.arainko.ducktape.internal.Plan[
[error]     |  io.github.arainko.ducktape.internal.Erroneous, F²].
[error]     |
[error]     |where:    F  is a type in class PossiblyFallible which is an alias of io.github.arainko.ducktape.internal.Fallible
[error]     |          F² is a type in method unapply with bounds <: io.github.arainko.ducktape.internal.Fallible
[error] -- [E172] Type Error: /Users/wmazur/projects/community-build3/repo/ducktape/src/main/scala/io/github/arainko/ducktape/internal/Planner.scala:296:11 
[error] 296 |          }
[error]     |           ^
[error]     |Cannot prove that io.github.arainko.ducktape.internal.Plan[
[error]     |  io.github.arainko.ducktape.internal.Erroneous, ctx.F] =:= io.github.arainko.ducktape.internal.Plan[
[error]     |  io.github.arainko.ducktape.internal.Erroneous, F²].
[error]     |
[error]     |where:    F  is a type in class PossiblyFallible which is an alias of io.github.arainko.ducktape.internal.Fallible
[error]     |          F² is a type in method unapply with bounds <: io.github.arainko.ducktape.internal.Fallible
[error] -- [E172] Type Error: /Users/wmazur/projects/community-build3/repo/ducktape/src/main/scala/io/github/arainko/ducktape/internal/Planner.scala:315:11 
[error] 315 |          }
[error]     |           ^
[error]     |Cannot prove that io.github.arainko.ducktape.internal.Plan[
[error]     |  io.github.arainko.ducktape.internal.Erroneous, ctx.F] =:= io.github.arainko.ducktape.internal.Plan[
[error]     |  io.github.arainko.ducktape.internal.Erroneous, F²].
[error]     |
[error]     |where:    F  is a type in class PossiblyFallible which is an alias of io.github.arainko.ducktape.internal.Fallible
[error]     |          F² is a type in method unapply with bounds <: io.github.arainko.ducktape.internal.Fallible
```

The constraint might be also applicable for other `current` methods used
to summon implicit, eg. `Mode.current` but I've not spotted any problems
with it so far
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-minor-release This PR cannot be merged until the next minor release release-notes Should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don’t apply wildcard approximation to non-transparent inlines in 3.4
3 participants