Skip to content

Commit

Permalink
Add test argumentTrailingComma and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kunli2 committed Nov 7, 2023
1 parent 5e9ae7d commit 6c37fea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,6 @@ private J visitNamedFunction0(KtNamedFunction function, ExecutionContext data) {
Set<PsiElement> prefixConsumedSet = new HashSet<>();
prefixConsumedSet.add(prefixConsumed);


if (function.getTypeParameterList() != null) {
typeParameters = new J.TypeParameters(
randomId(),
Expand Down Expand Up @@ -2474,11 +2473,7 @@ private J visitNamedFunction0(KtNamedFunction function, ExecutionContext data) {
), Markers.EMPTY
);
} else {
List<JRightPadded<Statement>> rps = new ArrayList<>();
for (KtParameter param : ktParameters) {
rps.add(padRight(convertToStatement(param.accept(this, data)), endFixAndSuffix(param)));
}
params = JContainer.build(prefix(function.getValueParameterList()), rps, Markers.EMPTY);
params = JContainer.build(prefix(function.getValueParameterList()), mapParameters(function.getValueParameterList(), data), Markers.EMPTY);
}

if (function.getReceiverTypeReference() != null) {
Expand Down Expand Up @@ -2514,7 +2509,6 @@ private J visitNamedFunction0(KtNamedFunction function, ExecutionContext data) {
newStatements.add(JRightPadded.build(implicitParam));
newStatements.addAll(params.getPadding().getElements());
params = params.getPadding().withElements(newStatements);

}

if (function.getTypeReference() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,28 @@ fun method2() {
)
);
}

@Test
void argumentTrailingComma() {
rewriteRun(
kotlin(
"""
inline fun <reified T, R> default(paramName: String): R? {
return null
}
class PersonProjection {
operator fun invoke() = this
}
public fun person(
a1: String? = default<PersonProjection, String?>("a1"),
a2: String,
_projection: PersonProjection.() -> PersonProjection, // Trailing Comma here
) {
}
"""
)
);
}
}

0 comments on commit 6c37fea

Please sign in to comment.