Do not report ACCIDENTAL_OVERRIDE on SAM adapters and such
This commit is contained in:
@@ -36,6 +36,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.diagnostics.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
@@ -334,6 +335,11 @@ public class GenerationState {
|
||||
// a member of super is not visible: no override
|
||||
continue;
|
||||
}
|
||||
if (member instanceof CallableMemberDescriptor &&
|
||||
CallResolverUtil.isOrOverridesSynthesized((CallableMemberDescriptor) member)) {
|
||||
// if a signature clashes with a SAM-adapter or something like that, there's no harm
|
||||
continue;
|
||||
}
|
||||
if (member instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) member;
|
||||
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: p/Sam.java
|
||||
|
||||
package p;
|
||||
|
||||
public interface Sam {
|
||||
void sam();
|
||||
}
|
||||
|
||||
// FILE: p/Foo.java
|
||||
|
||||
package p;
|
||||
|
||||
public class Foo {
|
||||
public void foo(Sam sam);
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import p.*
|
||||
|
||||
// to have enough fake overrides
|
||||
open class K0 : Foo()
|
||||
|
||||
class K : K0() {
|
||||
fun foo(f: () -> Unit) {}
|
||||
}
|
||||
@@ -2593,6 +2593,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest("compiler/testData/diagnostics/tests/duplicateJvmSignature/accidentalOverrides/genericClassFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("phantomClashWithSamAdapter.kt")
|
||||
public void testPhantomClashWithSamAdapter() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/duplicateJvmSignature/accidentalOverrides/phantomClashWithSamAdapter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateClassFunctionOverriddenByProperty.kt")
|
||||
public void testPrivateClassFunctionOverriddenByProperty() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/duplicateJvmSignature/accidentalOverrides/privateClassFunctionOverriddenByProperty.kt");
|
||||
|
||||
Reference in New Issue
Block a user