diff --git a/src/main/java/org/openrewrite/kotlin/internal/KotlinTreeParserVisitor.java b/src/main/java/org/openrewrite/kotlin/internal/KotlinTreeParserVisitor.java index ecb34ac04..73674728f 100644 --- a/src/main/java/org/openrewrite/kotlin/internal/KotlinTreeParserVisitor.java +++ b/src/main/java/org/openrewrite/kotlin/internal/KotlinTreeParserVisitor.java @@ -192,7 +192,7 @@ public J visitArrayAccessExpression(KtArrayAccessExpression expression, Executio JContainer args = JContainer.build(Space.EMPTY, expressions, markers); return new J.MethodInvocation( randomId(), - Space.EMPTY, + prefix(expression), markers, select, null, diff --git a/src/test/java/org/openrewrite/kotlin/tree/MethodInvocationTest.java b/src/test/java/org/openrewrite/kotlin/tree/MethodInvocationTest.java index f81b1451c..b7c3dc737 100644 --- a/src/test/java/org/openrewrite/kotlin/tree/MethodInvocationTest.java +++ b/src/test/java/org/openrewrite/kotlin/tree/MethodInvocationTest.java @@ -16,7 +16,6 @@ package org.openrewrite.kotlin.tree; import org.junit.jupiter.api.Test; -import org.junitpioneer.jupiter.ExpectedToFail; import org.openrewrite.Issue; import org.openrewrite.java.tree.J; import org.openrewrite.kotlin.marker.IndexedAccess; @@ -694,4 +693,22 @@ fun method() { ) ); } + + @Test + void namedParameters() { + rewriteRun( + kotlin( + """ + class Test { + fun foo(s: String) = s + fun bar(ss: Array) { + foo( + s = ss[0] + ) + } + } + """ + ) + ); + } }