Skip to content

Rewrite API so that Scala 3 would not rely on AutoDerived pattern (Scala 3.7 givens resolution change) #713

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

Merged
merged 18 commits into from
Apr 14, 2025

Conversation

MateuszKubuszok
Copy link
Member

@MateuszKubuszok MateuszKubuszok commented Mar 15, 2025

This PR solves the issue caused by 3.7 givens resolution change:

  • it no longer relies on this pattern

    trait TypeClass[A] extends TypeClass.AutoDerived[A]
    object TypeClass {
      trait AutoDerived[A]
      object AutoDerived {
        // summons TypeClass but NOT TypeClass.AutoDerived
        inline given [A]: AutoDerived[A] = ...
      } 
    }
    extension [A](value: A) def foo(using TypeClass.AutoDerived[A]) = ...

    for recursive (semi)automatic derivation

  • it uses new Expr.summonIgnoring

    trait TypeClass[A]
    object TypeClass {
      inline given derived[A]: AutoDerived[A] =
        ${ macroUsingSimmonIgnoring[A] }
        // Inside it uses:
        // Expr.summonIgnoring[TypeClass[A]](
        //  Symbol.classSymbol("TypeClass").companionModule.methodMember("derived")*
        // )
        // instead of Expr.summon[TypeClass[A]]
    }
    extension [A](value: A) def foo(using TypeClass[A]) = ...

  • remove AutoDerived on Scala 3
  • use summonIgnoring on Scala 3
  • fix failing tests
  • fix warnings and re-enable Xfatal-errors on Scala 3
    • currently warnings are disabled because of https://github.com/scala/scala3/
      issues/22812 - unblocked
    • fix warnings on chimney
    • fix warnings on chimney-cats
    • fix warnings on chimney-java-collections
    • fix warnings on chimney-protobufs
  • update documentation (differences between Scala 2 and 3 in 2.0.0)

@MateuszKubuszok MateuszKubuszok changed the title Rwwrite API so that Scala 3 would not rely on AutoDerived pattern Rewrite API so that Scala 3 would not rely on AutoDerived pattern Mar 15, 2025
@MateuszKubuszok MateuszKubuszok force-pushed the summon-ignoring-scala-3 branch from f4c3cc0 to 7950c17 Compare March 15, 2025 11:29
@MateuszKubuszok MateuszKubuszok force-pushed the summon-ignoring-scala-3 branch from 7950c17 to 6e41588 Compare March 15, 2025 11:35
Copy link

codecov bot commented Mar 20, 2025

Codecov Report

Attention: Patch coverage is 86.48649% with 20 lines in your changes missing coverage. Please review.

Project coverage is 86.98%. Comparing base (9862bb2) to head (628b442).
Report is 63 commits behind head on 2.0.0-development.

Files with missing lines Patch % Lines
...ey/internal/compiletime/ChimneyTypesPlatform.scala 44.44% 5 Missing ⚠️
...ey/internal/compiletime/ChimneyTypesPlatform.scala 50.00% 3 Missing ⚠️
...er/rules/TransformProductToProductRuleModule.scala 25.00% 3 Missing ⚠️
...mney/protobufs/ProtobufsTransformerImplicits.scala 91.30% 2 Missing ⚠️
...ime/derivation/transformer/ImplicitSummoning.scala 0.00% 2 Missing ⚠️
...rmSealedHierarchyToSealedHierarchyRuleModule.scala 33.33% 2 Missing ⚠️
...himney/internal/compiletime/DerivationResult.scala 0.00% 1 Missing ⚠️
...iletime/derivation/patcher/ImplicitSummoning.scala 0.00% 1 Missing ⚠️
...letime/derivation/transformer/Configurations.scala 80.00% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           2.0.0-development     #713      +/-   ##
=====================================================
- Coverage              87.10%   86.98%   -0.12%     
=====================================================
  Files                    154      157       +3     
  Lines                   7016     6748     -268     
  Branches                 727      651      -76     
=====================================================
- Hits                    6111     5870     -241     
+ Misses                   905      878      -27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MateuszKubuszok MateuszKubuszok changed the title Rewrite API so that Scala 3 would not rely on AutoDerived pattern Rewrite API so that Scala 3 would not rely on AutoDerived pattern (Scala 3.7 givens resolution change) Mar 20, 2025
@MateuszKubuszok MateuszKubuszok merged commit 628b442 into 2.0.0-development Apr 14, 2025
21 of 23 checks passed
@MateuszKubuszok MateuszKubuszok deleted the summon-ignoring-scala-3 branch April 14, 2025 09:31
implicit def liftTotal[From, To](implicit total: Transformer[From, To]): AutoDerived[From, To] =
(src: From, failFast: Boolean) => partial.Result.fromCatching(total.transform(src))
}
type AutoDerived[From, To] = Transformer[From, To]
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be PartialTransformer[From, To]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, yes, it should

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.

3 participants