Do not generate toString and other methods if they are inherited.
This commit is contained in:
@@ -37,6 +37,7 @@ import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
@@ -163,7 +164,7 @@ public class CodegenUtil {
|
||||
) {
|
||||
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getFunctions(name);
|
||||
for (FunctionDescriptor function : functions) {
|
||||
if (function.getKind() == CallableMemberDescriptor.Kind.DECLARATION
|
||||
if (!CallResolverUtil.isOrOverridesSynthesized(function)
|
||||
&& function.getTypeParameters().isEmpty()
|
||||
&& valueParameterClassesMatch(function.getValueParameters(), Arrays.asList(valueParameterClassifiers))
|
||||
&& rawTypeMatches(function.getReturnType(), returnedClassifier)) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
trait SuperTrait {
|
||||
public fun toString(): String = "!"
|
||||
}
|
||||
|
||||
data class A(val x: Int): SuperTrait {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return if (A(0).toString() == "!") "OK" else "fail"
|
||||
}
|
||||
+5
@@ -343,6 +343,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/alreadyDeclaredWrongSignature.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("alreadyInherited.kt")
|
||||
public void testAlreadyInherited() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/alreadyInherited.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("arrayParams.kt")
|
||||
public void testArrayParams() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/arrayParams.kt");
|
||||
|
||||
Reference in New Issue
Block a user