Fixed synthetic properties for method inherited from two bases
This commit is contained in:
+1
-2
@@ -110,7 +110,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by
|
||||
.asSequence()
|
||||
.flatMap { memberScope.getFunctions(it).asSequence() }
|
||||
.singleOrNull {
|
||||
it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE && isGoodGetMethod(it) && it.hasJavaOriginInHierarchy()
|
||||
isGoodGetMethod(it) && it.hasJavaOriginInHierarchy()
|
||||
} ?: return null
|
||||
|
||||
// don't accept "uRL" for "getURL" etc
|
||||
@@ -144,7 +144,6 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by
|
||||
val propertyType = getMethod.returnType ?: return false
|
||||
val parameter = descriptor.valueParameters.singleOrNull() ?: return false
|
||||
if (parameter.type != propertyType) {
|
||||
if (descriptor.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) return false // real setter must exactly match getter's type
|
||||
if (!propertyType.isSubtypeOf(parameter.type)) return false
|
||||
if (descriptor.findOverridden {
|
||||
val baseProperty = SyntheticJavaPropertyDescriptor.findByGetterOrSetter(it, this)
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
interface A {
|
||||
String getOk();
|
||||
}
|
||||
|
||||
interface B {
|
||||
String getOk();
|
||||
}
|
||||
|
||||
interface C extends A, B {
|
||||
}
|
||||
|
||||
class JavaClass implements C {
|
||||
public String getOk() { return "OK"; }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun box(): String {
|
||||
return f(JavaClass())
|
||||
}
|
||||
|
||||
fun f(c: C) = c.ok
|
||||
@@ -0,0 +1,19 @@
|
||||
// FILE: KotlinFile.kt
|
||||
|
||||
interface C : A, B
|
||||
|
||||
fun foo(c: C) {
|
||||
c.setSomething(c.getSomething() + 1)
|
||||
c.something++
|
||||
}
|
||||
|
||||
// FILE: A.java
|
||||
public interface A {
|
||||
int getSomething();
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public interface B {
|
||||
int getSomething();
|
||||
void setSomething(int value);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package
|
||||
|
||||
public /*synthesized*/ fun A(/*0*/ function: () -> kotlin.Int): A
|
||||
internal fun foo(/*0*/ c: C): kotlin.Unit
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun getSomething(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun getSomething(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal interface C : A, B {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract override /*2*/ /*fake_override*/ fun getSomething(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ fun foo(k: KotlinClass) {
|
||||
if (<!SENSELESS_COMPARISON!>k.something == null<!>) return
|
||||
|
||||
k.setSomething("")
|
||||
<!VAL_REASSIGNMENT!>k.something<!> = ""
|
||||
k.something = ""
|
||||
}
|
||||
|
||||
fun useString(<!UNUSED_PARAMETER!>i<!>: String) {}
|
||||
|
||||
@@ -14052,6 +14052,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FromTwoBases.kt")
|
||||
public void testFromTwoBases() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("GenericClass.kt")
|
||||
public void testGenericClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.kt");
|
||||
|
||||
+6
@@ -835,6 +835,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("fromTwoBases.kt")
|
||||
public void testFromTwoBases() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("getter.kt")
|
||||
public void testGetter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.kt");
|
||||
|
||||
Reference in New Issue
Block a user