Don't generate final modifier on static interface methods produced by @JvmStatic+@JvmOverloads from interface companion
#KT-35716 Fixed
This commit is contained in:
+4
-2
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi.KtParameter
|
|||||||
import org.jetbrains.kotlin.psi.KtPureClassOrObject
|
import org.jetbrains.kotlin.psi.KtPureClassOrObject
|
||||||
import org.jetbrains.kotlin.psi.KtPureElement
|
import org.jetbrains.kotlin.psi.KtPureElement
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorUtils.isInterface
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue
|
import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue
|
||||||
import org.jetbrains.kotlin.resolve.isInlineClass
|
import org.jetbrains.kotlin.resolve.isInlineClass
|
||||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||||
@@ -134,8 +135,9 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
|
|||||||
remainingParameters.map { DescriptorToSourceUtils.descriptorToDeclaration(it) as? KtParameter }
|
remainingParameters.map { DescriptorToSourceUtils.descriptorToDeclaration(it) as? KtParameter }
|
||||||
|
|
||||||
val generateAsFinal =
|
val generateAsFinal =
|
||||||
functionDescriptor.modality == Modality.FINAL ||
|
(functionDescriptor.modality == Modality.FINAL ||
|
||||||
state.languageVersionSettings.supportsFeature(LanguageFeature.GenerateJvmOverloadsAsFinal)
|
state.languageVersionSettings.supportsFeature(LanguageFeature.GenerateJvmOverloadsAsFinal)) &&
|
||||||
|
!isInterface(functionDescriptor.containingDeclaration)
|
||||||
val flags =
|
val flags =
|
||||||
baseMethodFlags or
|
baseMethodFlags or
|
||||||
(if (isStatic) Opcodes.ACC_STATIC else 0) or
|
(if (isStatic) Opcodes.ACC_STATIC else 0) or
|
||||||
|
|||||||
Generated
+5
@@ -17739,6 +17739,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35716.kt")
|
||||||
|
public void testKt35716() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897_static.kt")
|
@TestMetadata("kt9897_static.kt")
|
||||||
public void testKt9897_static() throws Exception {
|
public void testKt9897_static() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// JVM_TARGET: 1.8
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// FILE: Test.java
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
|
||||||
|
public static String test1() {
|
||||||
|
return A.sayHello();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: simpleCompanionObject.kt
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun sayHello(greeting: String = "OK"): String {
|
||||||
|
return greeting
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun box(): String {
|
||||||
|
if (Test.test1() != "OK") return "fail 1"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+5
@@ -19139,6 +19139,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35716.kt")
|
||||||
|
public void testKt35716() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897_static.kt")
|
@TestMetadata("kt9897_static.kt")
|
||||||
public void testKt9897_static() throws Exception {
|
public void testKt9897_static() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");
|
||||||
|
|||||||
+5
@@ -19139,6 +19139,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35716.kt")
|
||||||
|
public void testKt35716() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897_static.kt")
|
@TestMetadata("kt9897_static.kt")
|
||||||
public void testKt9897_static() throws Exception {
|
public void testKt9897_static() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");
|
||||||
|
|||||||
+5
@@ -17739,6 +17739,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt21246a.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt35716.kt")
|
||||||
|
public void testKt35716() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897_static.kt")
|
@TestMetadata("kt9897_static.kt")
|
||||||
public void testKt9897_static() throws Exception {
|
public void testKt9897_static() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user