JVM_IR: do not generate main() when extension main is present
Extension methods with signature C.main() should not cause generation of main(args: Array<String>).
This commit is contained in:
+5
-1
@@ -68,7 +68,11 @@ internal class MainMethodGenerationLowering(val context: JvmBackendContext) : Cl
|
||||
}
|
||||
|
||||
private fun IrSimpleFunction.isParameterlessMainMethod(): Boolean =
|
||||
typeParameters.isEmpty() && valueParameters.isEmpty() && returnType.isUnit() && name.asString() == "main"
|
||||
typeParameters.isEmpty() &&
|
||||
extensionReceiverParameter == null &&
|
||||
valueParameters.isEmpty() &&
|
||||
returnType.isUnit() &&
|
||||
name.asString() == "main"
|
||||
|
||||
|
||||
private fun IrSimpleFunction.isMainMethod(): Boolean {
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun Any.main() {}
|
||||
|
||||
// 0 main (\[Ljava/lang/String;)V
|
||||
@@ -3696,6 +3696,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/parameterlessMain"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnExtensionReceiver.kt")
|
||||
public void testDontGenerateOnExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnJvmNameMain.kt")
|
||||
public void testDontGenerateOnJvmNameMain() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnJvmNameMain.kt");
|
||||
|
||||
+5
@@ -3614,6 +3614,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/parameterlessMain"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnExtensionReceiver.kt")
|
||||
public void testDontGenerateOnExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnJvmNameMain.kt")
|
||||
public void testDontGenerateOnJvmNameMain() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnJvmNameMain.kt");
|
||||
|
||||
Reference in New Issue
Block a user