Skip to content

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

@anatoliykmetyuk

Description

@anatoliykmetyuk

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions