Can a main file method reference another main file method in the same package?

I have two files, a main file and a test file. Each file just has a main method in it, no actual class definition. Is it possible to reference the main method from the main file in the test main method?


package com.skater901

fun main(args: Array<String>) {
   // run my app


package com.skater901

fun main(args: Array<String>) {
    // setup code for local debugging

    com.skater901.MainKt.main(args) <--- MainKt is red

    com.skater901.Main.main(args) <--- Main is red

Is there actually a way to do this, or do I have to make one of these files have an actual class in it, so the path to the method is different?

I think you should be abe to reference main from production code in test code if you change package where your test main is declared. Then you can simply reference it by:

But can I do it if they’re in the same package? I know I can move it to a different package, and I know I can put one (or both) method(s) inside a class, but I’d prefer not to do either of those things if possible.

AFAIK no, but I could be wrong.

com.skater901.MainKt.main is how you call Kotlin from Java. I do not want to use this notation when calling Kotlin from Kotlin. AFAIK