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

Enumerate transitive self types #162

Merged
merged 1 commit into from
Jan 18, 2022
Merged

Conversation

eed3si9n
Copy link
Member

@eed3si9n eed3si9n commented Jan 18, 2022

Fixes #159

Problem

In Scala 3 self type must enumerate the transitive self types,
which in the context of codecs means all the Formats traits for
all the fields in the child trait, not just that of child traits.

trait XFormats { self: YFormats => }

trait YFormats { self: ZFormats => }

trait ZFormats

In Scala 3, the above won't compile complaining

scala> trait XFormats { self: YFormats => }
     | trait YFormats { self: ZFormats => }
     | trait ZFormats
     |
-- Error:
1 |trait XFormats { self: YFormats => }
  |      ^
  |missing requirement: self type YFormats & XFormats of trait XFormats does not conform to self type ZFormats
  |of required trait YFormats

Solution

This genenrally improves the lookup of format type,
first by traversing lazy type, list type, and non-null type,
and looking up the named types in the local schema.
Then recursively all fields' format types are returned to generate
the list of self types.

In general though, since the protocol object that extends all traits
have been working fine in Scala 2, this mostly amounts to
type beurocracy to satisfy Scala 3 (lampepfl/dotty 2214).

Fixes sbt#159

Problem
-------
In Scala 3 self type must enumerate the transitive self types,
which in the context of codecs means all the Formats traits for
all the fields in the child trait, not just that of child traits.

Solution
--------
This genenrally improves the lookup of format type,
first by traversing lazy type, list type, and non-null type,
and looking up the named types in the local schema.
Then recursively all fields' format types are returned to generate
the list of self types.

In general though, since the protocol object that extends all traits
have been working fine in Scala 2, this mostly amounts to
type beurocracy to satisfy Scala 3 (lampepfl/dotty 2214).
@eed3si9n eed3si9n merged commit 106a608 into sbt:develop Jan 18, 2022
@eed3si9n eed3si9n deleted the wip/selftype branch January 18, 2022 03:26
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.

self type specification is not enough for Scala 3
1 participant