Skip to content

Commit

Permalink
Use convert to expression in visitQualifiedExpression.
Browse files Browse the repository at this point in the history
  • Loading branch information
traceyyoshima committed Nov 15, 2023
1 parent 4e75cef commit 7824a77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,8 @@ public J visitPropertyAccessor(KtPropertyAccessor accessor, ExecutionContext dat

@Override
public J visitQualifiedExpression(KtQualifiedExpression expression, ExecutionContext data) {
Expression receiver = (Expression) expression.getReceiverExpression().accept(this, data);
Expression selector = (Expression) requireNonNull(expression.getSelectorExpression()).accept(this, data);
Expression receiver = convertToExpression(expression.getReceiverExpression().accept(this, data));
Expression selector = convertToExpression(requireNonNull(expression.getSelectorExpression()).accept(this, data));
if (selector instanceof J.MethodInvocation) {
J.MethodInvocation methodInvocation = (J.MethodInvocation) selector;
return methodInvocation.getPadding()
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/openrewrite/kotlin/tree/IfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ fun foo(arg: String = if (enabled) "foo" else "bar"): String {
);
}

@Issue("https://github.com/openrewrite/rewrite-kotlin/issues/394")
@Test
void fieldAccess() {
rewriteRun(
kotlin(
"""
val foo = if (true) { "" } else { null }?.plus("bar")
"""
)
);
}

@Issue("https://github.com/openrewrite/rewrite-kotlin/issues/392")
@Test
void postfixExpression() {
Expand Down

0 comments on commit 7824a77

Please sign in to comment.