Skip to content

Commit

Permalink
Fix typeAliasWithModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
kunli2 committed Nov 10, 2023
1 parent 314267f commit dadb295
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1224,10 +1224,9 @@ public J visitTypeAlias(KtTypeAlias typeAlias, ExecutionContext data) {
List<J.Annotation> lastAnnotations = new ArrayList<>();
Set<PsiElement> consumedSpaces = preConsumedInfix(typeAlias);

modifiers.addAll(mapModifiers(typeAlias.getModifierList(), leadingAnnotations, lastAnnotations, data));
modifiers.add(new J.Modifier(randomId(), prefix(typeAlias.getTypeAliasKeyword(), consumedSpaces), markers, "typealias", J.Modifier.Type.LanguageExtension, emptyList()));

mapModifiers(typeAlias.getModifierList(), leadingAnnotations, lastAnnotations, data);

if (typeAlias.getIdentifyingElement() == null) {
throw new UnsupportedOperationException("TODO");
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/openrewrite/kotlin/tree/TypeAliasTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,16 @@ void typeAliasForFunctionType() {
)
);
}

@Issue("https://github.com/openrewrite/rewrite-kotlin/issues/375")
@Test
void typeAliasWithModifier() {
rewriteRun(
kotlin(
"""
internal typealias Action = (String) -> Unit
"""
)
);
}
}

1 comment on commit dadb295

@kunli2
Copy link
Contributor Author

@kunli2 kunli2 commented on dadb295 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #375

Please sign in to comment.