diff --git a/src/main/java/org/openrewrite/kotlin/internal/KotlinTreeParserVisitor.java b/src/main/java/org/openrewrite/kotlin/internal/KotlinTreeParserVisitor.java index cab83f1ba..b159eb7d3 100644 --- a/src/main/java/org/openrewrite/kotlin/internal/KotlinTreeParserVisitor.java +++ b/src/main/java/org/openrewrite/kotlin/internal/KotlinTreeParserVisitor.java @@ -774,7 +774,9 @@ public J visitNamedDeclaration(KtNamedDeclaration declaration, ExecutionContext @Override public J visitNullableType(KtNullableType nullableType, ExecutionContext data) { J j = requireNonNull(nullableType.getInnerType()).accept(this, data); - return j.withMarkers(j.getMarkers().addIfAbsent(new IsNullable(randomId(), suffix(nullableType.getInnerType())))); + return j.withMarkers(j.getMarkers().addIfAbsent(new IsNullable(randomId(), + prefix((PsiElement) nullableType.getQuestionMarkNode()) + ))); } @Override @@ -1803,7 +1805,7 @@ public J visitBlockExpression(KtBlockExpression expression, ExecutionContext dat } boolean hasBraces = expression.getLBrace() != null; - Space end = hasBraces ? endFixPrefixAndInfix(expression.getRBrace()) : endFix(expression); + Space end = hasBraces ? deepPrefix(expression.getRBrace()) : Space.EMPTY; Space prefix = prefix(expression); Space blockPrefix = prefix; diff --git a/src/test/java/org/openrewrite/kotlin/tree/FunctionTypeTest.java b/src/test/java/org/openrewrite/kotlin/tree/FunctionTypeTest.java index 6272faac4..1314934de 100644 --- a/src/test/java/org/openrewrite/kotlin/tree/FunctionTypeTest.java +++ b/src/test/java/org/openrewrite/kotlin/tree/FunctionTypeTest.java @@ -88,7 +88,7 @@ void parenthesizedNullableType() { rewriteRun( kotlin( """ - val v: ((Any) -> Any)? = null + val v: ( ( Any ) -> Any) /*c1*/ ? = null """ ) ); diff --git a/src/test/java/org/openrewrite/kotlin/tree/KTSTest.java b/src/test/java/org/openrewrite/kotlin/tree/KTSTest.java index 62fffe889..edaecace4 100644 --- a/src/test/java/org/openrewrite/kotlin/tree/KTSTest.java +++ b/src/test/java/org/openrewrite/kotlin/tree/KTSTest.java @@ -32,7 +32,7 @@ void topLevelAssignmentExpression() { rewriteRun( kotlinScript(""" var x = 5 - x += 1 + x += 1 /*C1*/ """) ); }