Skip to content

Unexpected non-private type access #7859

Closed
@Atry

Description

@Atry

minimized code

  trait Lub2[A, B] {
    type Output
  }
  given [A <: C, B <: C, C]: Lub2[A, B] {
    type Output = C
  }

  trait Lub[Union] {
    type Output
  }

  given [A]:Lub[A] {
    type Output = A
  }

  // non-private type Output in class given_Lub_Left refers to private value lub2
  // in its type signature  = given_Lub_Left.this.lub2.Output
  given [Left, Right](given lubLeft: Lub[Right], lubRight: Lub[Right])(given lub2: Lub2[lubLeft.Output, lubRight.Output]): Lub[Left | Right] {
    type Output = lub2.Output
  }

expectation

It should compile because the identical code compiles as following:

  given [Left, Right](given lubLeft: Lub[Right], lubRight: Lub[Right])(given lub2: Lub2[lubLeft.Output, lubRight.Output]): (Lub[Left | Right] {
    type Output = lub2.Output
  }) = new Lub[Left | Right] {
    type Output = lub2.Output
  }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions