File tree 1 file changed +12
-0
lines changed
src/dotty/tools/dotc/transform
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,18 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
33
33
case _ => (Nil , Nil )
34
34
}
35
35
def inheritedAccessor (sym : Symbol ): Symbol = {
36
+ /**
37
+ * Dmitry: having it have the same name is needed to maintain correctness in presence of subclassing
38
+ * if you would use parent param-name `a` to implement param-field `b`
39
+ * overriding field `b` will actually override field `a`, that is wrong!
40
+ *
41
+ * class A(val s: Int);
42
+ * class B(val b: Int) extends A(b)
43
+ * class C extends A(2) {
44
+ * def s = 3
45
+ * assert(this.b == 2)
46
+ * }
47
+ */
36
48
val candidate = sym.owner.asClass.superClass
37
49
.info.decl(sym.name).suchThat(_ is (ParamAccessor , butNot = Mutable )).symbol
38
50
if (candidate.isAccessibleFrom(currentClass.thisType, superAccess = true )) candidate
You can’t perform that action at this time.
0 commit comments