diff --git a/src/main/java/org/openrewrite/kotlin/format/TabsAndIndentsVisitor.java b/src/main/java/org/openrewrite/kotlin/format/TabsAndIndentsVisitor.java index d0542b3d..df8a1c0f 100644 --- a/src/main/java/org/openrewrite/kotlin/format/TabsAndIndentsVisitor.java +++ b/src/main/java/org/openrewrite/kotlin/format/TabsAndIndentsVisitor.java @@ -171,8 +171,8 @@ public Space visitSpace(Space space, Space.Location loc, P p) { } } - if (loc == Space.Location.MODIFIER_PREFIX && value instanceof J.MethodDeclaration) { - J.MethodDeclaration m = getCursor().getValue(); + if (loc == Space.Location.MODIFIER_PREFIX && value instanceof J.Modifier && parent.getValue() instanceof J.MethodDeclaration) { + J.MethodDeclaration m = parent.getValue(); if (!m.getLeadingAnnotations().isEmpty()) { alignToAnnotation = true; }