Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

No way to specify encapsulation modifier for given params of given classes #7045

Closed
anatoliykmetyuk opened this issue Aug 15, 2019 · 1 comment · Fixed by #16293
Closed
Assignees
Milestone

Comments

@anatoliykmetyuk
Copy link
Contributor

minimized code

scala> trait Bar { type Y }
// defined trait Bar

scala> trait Foo { type X }
// defined trait Foo


scala> given as Foo given (b: Bar) { type X = b.Y }
1 |given as Foo given (b: Bar) { type X = b.Y }
  |                                   ^
  |           non-private type X in class Foo_given refers to private value b
  |           in its type signature  = Foo_given.this.b.Y

scala> given as Foo given (val b: Bar) { type X = b.Y }
1 |given as Foo given (val b: Bar) { type X = b.Y }
  |                    ^^^
  |                    an identifier expected, but 'val' found

Workaround:

scala> given as Foo given (b: Bar) = new Foo { type X = b.Y }
def Foo_given given (b: Bar): Foo

expectation

I'd like to use the nicer syntax without the workaround.

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jan 9, 2020

With updated syntax

trait Bar { type Y }
trait Foo { type X }

given a(using val b: Bar) as Foo { type X = b.Y }
6 |given a(using val b: Bar) as Foo { type X = b.Y }
  |              ^^^
  |              an identifier expected, but 'val' found

@dwijnand dwijnand linked a pull request Nov 7, 2022 that will close this issue
@dwijnand dwijnand self-assigned this Nov 7, 2022
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants