fix bug in arg preprocessor
diff --git a/kotlin/builder/src/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt b/kotlin/builder/src/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt
index e4d104d..baa7f49 100644
--- a/kotlin/builder/src/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt
+++ b/kotlin/builder/src/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt
@@ -16,6 +16,7 @@
 package io.bazel.kotlin.compiler
 
 import org.jetbrains.kotlin.cli.common.ExitCode
+import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
 import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
 import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
 import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
@@ -23,14 +24,14 @@
 
 @Suppress("unused")
 class BazelK2JVMCompiler(private val delegate: K2JVMCompiler = K2JVMCompiler()) {
-    private lateinit var friendsPaths: Array<String>
+    private fun createArgs(args: Array<out String>): K2JVMCompilerArguments {
+        var friendsPaths: Array<String>? = null
 
-    private fun preprocessArgs(args: Array<out String>): Array<out String> {
         val tally = mutableListOf<String>()
-        var i =0
+        var i = 0
         do {
             when {
-                // https://github.com/bazelbuild/rules_kotlin/issues/69: remove once jetbrains adds a flag for it.
+            // https://github.com/bazelbuild/rules_kotlin/issues/69: remove once jetbrains adds a flag for it.
                 args[i].startsWith("--friend-paths") -> {
                     i++
                     friendsPaths = args[i].split(":").toTypedArray()
@@ -38,17 +39,18 @@
                 else -> tally += args[i]
             }
             i++
-        } while(i < args.size)
-        return tally.toTypedArray()
-    }
+        } while (i < args.size)
 
-    fun exec(errStream: java.io.PrintStream, vararg args: kotlin.String): ExitCode {
-        val arguments = delegate.createArguments().also {
-            delegate.parseArguments(preprocessArgs(args), it)
-            if(::friendsPaths.isInitialized) {
+        return delegate.createArguments().also {
+            delegate.parseArguments(tally.toTypedArray(), it)
+            if (friendsPaths != null) {
                 it.friendPaths = friendsPaths
             }
         }
+    }
+
+    fun exec(errStream: java.io.PrintStream, vararg args: kotlin.String): ExitCode {
+        val arguments = createArgs(args)
         val collector = PrintingMessageCollector(errStream, MessageRenderer.PLAIN_RELATIVE_PATHS, arguments.verbose)
         return delegate.exec(collector, Services.EMPTY, arguments)
     }