-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inlining failure when accessing same-named private members in sub and superclass #15612
Comments
MinimizationA bit smaller example: class Parent[E](using u: Unit):
inline def m: Any = u
class Klass[E](using u: Unit) extends Parent[E]:
inline def n: Any = u Error: -- [E164] Declaration Error: tests/pos/i15612.scala:4:21 -----------------------
4 |class Klass[E](using u: Unit) extends Parent[E]:
| ^
|error overriding method inline$u in class Parent of type => Unit;
| method inline$u of type => Unit cannot override final member method inline$u in class Parent ExplanationThe first commit that breaks this is: 13df1bc The problem here is that the Generated tree (after refchecks): package <empty> {
@SourceFile("tests/pos/i15612.scala") class Parent[E](using u: Unit) extends
Object
() {
E
private[this] given val u: Unit
inline def m: Any = this.inline$u:Any
final def inline$u: Unit = Parent.this.u
}
@SourceFile("tests/pos/i15612.scala") class Klass[E](using u: Unit) extends
Parent[E]
(u)() {
E
private[this] given val u: Unit
inline def n: Any = this.inline$u:Any
final def inline$u: Unit = Klass.this.u
}
} WorkaroundA possible workaround here is to make those class Parent[E](using protected val u: Unit):
inline def m: Any = u
class Klass[E](using override protected val u: Unit) extends Parent[E]:
inline def n: Any = u |
Minimization: class A:
private val a = 1
inline def foo() = a
class B extends A:
private val a = 2
inline def bar() = a |
Based on the community build failure https://scala3.westeurope.cloudapp.azure.com/blue/organizations/jenkins/buildCommunityProject/detail/buildCommunityProject/1136/pipeline/
Library maintainer @tabdulradi
Problem exists only if both open classes define extension methods using type matching
Compiler version
Works in 3.1.3
Fails in 3.2.0-RC1 and RC2
Fails in 3.2.1-RC1-bin-20220706-9d07d52-NIGHTLY
Minimized code
Output
Expectation
Should compile
The text was updated successfully, but these errors were encountered: