Do not add extra 'this' parameter for TImpl's accessor
Fixes weird cases like super-call from a closure inside a trait with a required class
This commit is contained in:
@@ -519,8 +519,6 @@ public class JetTypeMapper extends BindingTraceAware {
|
|||||||
|
|
||||||
signatureVisitor.writeParametersStart();
|
signatureVisitor.writeParametersStart();
|
||||||
|
|
||||||
writeThisForAccessorIfNeeded(f, signatureVisitor);
|
|
||||||
|
|
||||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||||
ClassDescriptor containingDeclaration = (ClassDescriptor) f.getContainingDeclaration();
|
ClassDescriptor containingDeclaration = (ClassDescriptor) f.getContainingDeclaration();
|
||||||
JetType jetType = CodegenUtil.getSuperClass(containingDeclaration);
|
JetType jetType = CodegenUtil.getSuperClass(containingDeclaration);
|
||||||
@@ -534,6 +532,9 @@ public class JetTypeMapper extends BindingTraceAware {
|
|||||||
signatureVisitor.writeAsmType(type, jetType.isNullable());
|
signatureVisitor.writeAsmType(type, jetType.isNullable());
|
||||||
signatureVisitor.writeParameterTypeEnd();
|
signatureVisitor.writeParameterTypeEnd();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
writeThisForAccessorIfNeeded(f, signatureVisitor);
|
||||||
|
}
|
||||||
|
|
||||||
if (receiverType != null) {
|
if (receiverType != null) {
|
||||||
signatureVisitor.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
signatureVisitor.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
open class Base {
|
||||||
|
open fun foo() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Derived : Base {
|
||||||
|
override fun foo() {
|
||||||
|
super.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DerivedImpl : Derived, Base()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
DerivedImpl().foo()
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
open class Base {
|
||||||
|
open fun foo() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Derived : Base {
|
||||||
|
override fun foo() {
|
||||||
|
object {
|
||||||
|
fun bar() {
|
||||||
|
super<Base>@Derived.foo()
|
||||||
|
}
|
||||||
|
}.bar()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DerivedImpl : Derived, Base()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
DerivedImpl().foo()
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -88,4 +88,12 @@ public class TraitsTest extends CodegenTestCase {
|
|||||||
public void testKt2963() {
|
public void testKt2963() {
|
||||||
blackBoxFile("regressions/kt2963.kt");
|
blackBoxFile("regressions/kt2963.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testWithRequiredSuper() {
|
||||||
|
blackBoxFile("traits/withRequiredSuper.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testWithRequiredSuperViaBridge() {
|
||||||
|
blackBoxFile("traits/withRequiredSuperViaBridge.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user