Proguard can't process this simple code

I’ve found the problem in my codebase and I’ve tried to simplify it to the following snippet:

class DemoProguardIssue {
    fun main() {
        with(Unit) {
            runLambda {
                runLambda {

                }
            }
        }
    }
    private fun runLambda(lambda: () -> Unit) = lambda()
}

Proguard complains with this error and breaks my build

Warning: com.example.DemoProguardIssue$main$1$1$1: can't find referenced class com.example.DemoProguardIssue$main$1$1

Rewriting the code to avoid the with was an easy workaround for me, but I’m scared there’s a bug in the compiler, or the desugar tool or something.

Can you help me figure out the problem?

1 Like

Just curious: why do you use “with(Unit)”? What is the purpose?

1 Like

This snippet is my best effort to simplify the code and still reproduce the issue. In the actual code the with uses another object.
But proguard won’t complain if you remove the useless with(Unit)

I have the same issue, you should file a bug report

Filed on Sourceforge

It’s actually a Kotlin issue, it has been reported here : https://youtrack.jetbrains.com/issue/KT-16084