Skip to content

Bad interaction between self alias and opaque types #8143

Closed
@nicolasstucki

Description

@nicolasstucki

minimized code

class Reflection(val internal: CompilerInterface) { self => // It works if the self is removed
  opaque type Flags = internal.Flags
  object Flags {
    def EmptyFlags: Flags = internal.Flags_EmptyFlags
  }
}

trait CompilerInterface {
  type Flags
  def Flags_EmptyFlags: Flags
}

Compilation output

-- [E007] Type Mismatch Error: Foo.scala:7:37 ----------------------------------
7 |    def EmptyFlags: Flags = internal.Flags_EmptyFlags
  |                            ^^^^^^^^^^^^^^^^^^^^^^^^^
  |                     Found:    Reflection.this.internal.Flags
  |                     Required: Reflection.this.Flags²
  |
  |                     where:    Flags  is a type in trait CompilerInterface
  |                               Flags² is a type in class Reflection

expectation

It should compile and be equivalent to the class without a self

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions