Skip to content

Commit

Permalink
Prevent NPE when processing old LSTs
Browse files Browse the repository at this point in the history
  • Loading branch information
traceyyoshima authored and knutwannheden committed Nov 14, 2023
1 parent de58a48 commit 836eb63
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/openrewrite/kotlin/tree/K.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.openrewrite.kotlin.tree;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.*;
import lombok.experimental.FieldDefaults;
Expand Down Expand Up @@ -1094,7 +1093,9 @@ public FunctionType withParameters(List<TypeTree> parameters) {

@Override
public @Nullable JavaType getType() {
return returnType.getElement().getType();
// for backwards compatibility with older LST before there was a returnType field
//noinspection ConstantValue
return returnType != null ? returnType.getElement().getType() : null;
}

public <T extends J> T withType(@Nullable JavaType type) {
Expand Down

0 comments on commit 836eb63

Please sign in to comment.