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

Rewrite of the code with initial Scala 3 implementation, fixes #201 #325

Merged
merged 200 commits into from
Aug 3, 2023

Conversation

MateuszKubuszok
Copy link
Member

@MateuszKubuszok MateuszKubuszok commented Jul 7, 2023

DONE:

  • rewritten whole derivation code from Scala 2-macro-implementation-tied, mostly untyped and lacking significant naming to more platform-agnostic and typed utilities with better names
  • provided platform-specific implementations for platform-agnostic interfaces in Scala 2 and in Scala 3
  • wired Scala 3 DSL to Scala 3 macros
  • removed old macros
  • removed deprecated features
    • TransformerFs
    • enableUnsafeOption flag
    • tests and benchmarks for the above
  • split Transformer into Transformer and Transformer.AutoDerived, to avoid
    1. potentially expanding macros in implicit lookup, because it was catching not only user-provided implicits
    2. checking that this implicit was created by autoderivation macro (which introduces unnecessary boxing and ignores configs)
    3. discarding obtained implicit when it was autoderived
    4. effectively wasting CPU work
  • sorted code inside internal package into internal.runtime, internal.compiletime.dsl, internal.compiletime.derivation, etc
  • improved error logging in a few places
  • added the ability to display structured logs from macro expansion (.enableMacrosLogging)

TODO:

krzemin and others added 30 commits April 19, 2023 13:53
- cleanup majority of the compilation warnings
- cleanup unused warnings from macro-generated code (Scala 2 only)
* The first draft of an elternative structure for macros towards which current code could be migrated, one rule by one

* Small cleanup

* fixup! Small cleanup

* Split Transformer, PartialTransformer and Patcher into shared code and *Platform files

* Initial Scala 3 implementation for some of compiletime abstractions

* Remodel new types abstractions a bit

* Move logging from Context to DerivationResult

* Add missing abstractions from old macros

* Refactor Types/Exprs module (#293)

* Refactor Types abstractions:

- split Types (language & stdlib types) and ChimneyTypes (library-specific types)
- simplify the API structure

* Restructure Scala 2 platform types impl

* make Scala 2 code compiling

* implement Scala 3 types, make it compile

* refactor Exprs interface

* implementation of new Expr interface for Scala 2

* implementation of new Expr interface for Scala 3

* remove unused code

* resolved TODO comments with implicit exprs resolution

* uncomment code

* Share TransformerDefinitionErrors, split TransformerContext and PatcherContext, fix legacy macro workaround implementation (#294)

* Share TransformerDefinitionErrors, split TransformerContext and PatcherContext, fix legacy macro workaround implementation

* Improve error handling in Results

* Move DerivationResult to a separate file outside mix-in

* Remove unnecessary src = src

* Fix to actually use the implementation in Gateway

* Remove resolved todo in reportError

* Align transformerDefinitionPrefix type with what is used in legacy macros, use proper error reporing in flag parsing

* Move derivation related traits to transformer subpackage

---------

Co-authored-by: Piotr Krzemiński <[email protected]>
* The first draft of an elternative structure for macros towards which current code could be migrated, one rule by one

* Small cleanup

* fixup! Small cleanup

* Initial Scala 3 implementation for some of compiletime abstractions

* Scala 3 DSL

type params renaming

refactor: simplify package structure, renamings

comment about StringBounded workaround and SIP-53

remove unnecessary imports

go back to stable scala 3

migrate cats module to shared directory (including tests)

fix compilation of cats tests

extract issues related fixtures to a separate file

refactor: rename package examples -> fixtures

remove scala version dependent tests

moving issues tests to shared, compilation fixes for scala 3

moving pb tests to shared

moving partial tests to shared

moving partial tests to shared, bugfixing partial dsl

fixing partial dsl

scala 3 PartialTransformerInto

implement partial transformer definition for scala 3

fix macro impl type signature

implement scala 3 patcher dsl

move partial result spec to shared dir

move total sum types spec to shared dir

move total java beans spec to shared dir

compilation fixes: total product spec

wip: moving total transformer tests to shared directory

move first total transformer test suite to shared dir, make tests compiling under scala 3

TransformerInto: simplified transform impl

no transaprent inline for buildTransformer

wip: TransformerInto methods

wip: TransformerInto prototyping

don't use erased as it still experimental language feature

rename type param

buildTransformer stub impl

adhere to scala-2 withFieldRenamed semantics for selectors extraction

refactor DslUtils

prototyped withCoproductInstance

prototyped withFieldRenamed

simplify implementation

prototyped withFieldComputed

factor out impl to a separate module

prototype implementation of withFieldConst in TransformerDefinition

* make code compiling after rebase

---------

Co-authored-by: Mateusz Kubuszok <[email protected]>
- remove reference to non-existing code
- put missing fixture in a proper place
* First Rule interface draft

* Add pretty printing of Types and Exprs and use them to print errors when no rule is matched

* Move Rule to Derivation since it's the only place which would make use if it

* Implement Transformer-body-to-Transformer lifting

* Remove Legacy and Legacy platform and instead move their code to DerivationWithLegacyMacros which use their former code as rule

* Simplified architecture after discussion: lifting to type classes is only done at the edges, legacy macro rules inner methods are moved inside an object

* Create entrypoint for new macros in Scala 2 and Scala 3

* Removed unnecessary shared DSL leftover

* Fix Scala 3 DSL macros package naming

* scala 3 flags parsing

* Abstraction for extracting data from RuntimeDataStore

* simplify RuntimeDataStoreModule

* simplify transformer config

* reading transformer config impl for scala 2

* simplify method signatures (remove no longer needed From/To types)

* reading transformer config impl for scala 3

* simplify scala 2 impl (remove no longer needed implicit parameters)

* implementation of transformer subtyping rule

* instantiate new macros for scala 2

* fix expected error messages in tests

* adjust name of scala 3 macro bundle to scala 2 name

* wip: trying to wire scala 3 macro

* Fix accidental infinite recursion in Scala 3 TypesPlatform

* Wired PartialTransformer autoderivation, added a few debyg utils and fixed a few errors in our implementation to make PartialTransformer autoderivation work

* Rename legacy macros fallback rule to keep convention

* Add RuntimeDataStore to Contexts and pass it from .buildTransformer in Scala 3

* Fix Scala 2 dsl endpoints in new macros after changes to runtimedata store

* fixing implementation of scala 3 dsl (TransformerInto) for config encofing/reading

* wiring `.transform` method impl without type class instantiation

* fixing implementation of scala 3 dsl (PartialTransformerInto) for config encoding/reading

* bump scala to latest 3.3.0 RC version

* added missing transformFailFast to PartialTransformerInto; added test

* wiring `.transform` and `.transformFailFast` method implementations in PartialTransformerInto without type class instantiation

* implement asStringSingletonType for Scala 3

* simplify syntax and impl for Scala 3 asStringSingletonType extension

* Use type matches to dispatching deriveTransformationResult

* Standardize names for dlags taken from implicit scope config value

* Rename LocalConfigType to ImplicitScopeFlagsType

* Remove warning from FielNameUtils

* make runtimeDataStore expr obligatory in contexts

* code cleanups

* another bunch of code cleanups

* renamings in transformer macros

* remove debug println

* rename in legacy code to keep consistency

* unify error messages for bad config/flag type shapes

* reorganize singleton string type extensions

* remove irrelevant TODO comments

* remove unused/commented code

---------

Co-authored-by: Piotr Krzemiński <[email protected]>
* Preprare diagnostic logging infrastructure in TransformerDerivation macros

* Add derivationLog flag and DerivationResult logs to trace recursive derivation and rules matching

* Add logging of contexts

* Rename DerivationLog to MacrosLogging

* explicit rule expansion results + custom
rule sequence interpreter; improve logs printing

---------

Co-authored-by: Piotr Krzemiński <[email protected]>
@MateuszKubuszok MateuszKubuszok temporarily deployed to benchmark August 1, 2023 22:13 — with GitHub Actions Inactive
@MateuszKubuszok MateuszKubuszok changed the title Scala 3 draft, fixes #201 Rewrite of the code with initial Scala 3 implementation, fixes #201 Aug 2, 2023
README.md Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
* Add linters to Scala 3

* Suppress unckecked warnings

* Enable -Xfatal-warnings
@krzemin krzemin temporarily deployed to benchmark August 2, 2023 11:22 — with GitHub Actions Inactive
@krzemin krzemin temporarily deployed to benchmark August 2, 2023 11:39 — with GitHub Actions Inactive
@krzemin krzemin temporarily deployed to benchmark August 2, 2023 12:14 — with GitHub Actions Inactive
@krzemin krzemin temporarily deployed to benchmark August 2, 2023 14:56 — with GitHub Actions Inactive
@krzemin krzemin temporarily deployed to benchmark August 2, 2023 21:04 — with GitHub Actions Inactive
* Add Scala 3's enum specs, rename SumTypeSpecs to SealedHierarchySpecs to avoid confusion with Scala 3' sum types

* Fix enums implementation on Scala 3
@MateuszKubuszok MateuszKubuszok merged commit d239264 into master Aug 3, 2023
36 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark Added to PRs which should be benchmarked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scala 3 support
3 participants