Skip to content

Private member shadows inherited member #7475

Description

@scabug

Depending on order of traits, private members can shadow inherited members and prevent compilation. This does not happen with separate compilation.

scala> :pa
// Entering paste mode (ctrl-D to finish)

trait A { private val x = 1 }
trait B { val x = 2 }
trait C extends B with A { println(x) }

// Exiting paste mode, now interpreting.

<console>:9: error: value x in trait A cannot be accessed in C
       trait C extends B with A { println(x) }
                                          ^

scala> :reset
Resetting interpreter state.

scala> trait A { private val x = 1 }
defined trait A

scala> trait B { val x = 2 }
defined trait B

scala> trait C extends B with A { println(x) }
defined trait C

Expected behavior (to me anyway) is that private members (which are not inherited) should not shadow inherited members when resolving symbols in subclasses. But in either case behavior should be consistent between combined and separate compilation.

Edit: damn this editor/formatter.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions