From 289e80969eb47b3c8768a305dec96c0213189f41 Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Tue, 31 Oct 2023 14:13:10 +0100 Subject: [PATCH] Allow for deserialized `JavaType.Unknown` instances These can't be compared with referential equality against `JavaType.Unknown.getInstance()`. --- .../java/internal/DefaultJavaTypeSignatureBuilder.java | 2 +- .../src/main/java/org/openrewrite/java/tree/TypeUtils.java | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/rewrite-java/src/main/java/org/openrewrite/java/internal/DefaultJavaTypeSignatureBuilder.java b/rewrite-java/src/main/java/org/openrewrite/java/internal/DefaultJavaTypeSignatureBuilder.java index 41ef289941b..3ea3f891025 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/internal/DefaultJavaTypeSignatureBuilder.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/internal/DefaultJavaTypeSignatureBuilder.java @@ -30,7 +30,7 @@ public class DefaultJavaTypeSignatureBuilder implements JavaTypeSignatureBuilder @Override public String signature(@Nullable Object type) { - if (type == null || type == JavaType.Unknown.getInstance()) { + if (type == null || type instanceof JavaType.Unknown) { return "{undefined}"; } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/tree/TypeUtils.java b/rewrite-java/src/main/java/org/openrewrite/java/tree/TypeUtils.java index 52f9382f0f3..e61b423b2f0 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/tree/TypeUtils.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/tree/TypeUtils.java @@ -381,10 +381,7 @@ public static JavaType.Primitive asPrimitive(@Nullable JavaType type) { @Nullable public static JavaType.FullyQualified asFullyQualified(@Nullable JavaType type) { - if (type instanceof JavaType.FullyQualified) { - if (type == JavaType.Unknown.getInstance()) { - return null; - } + if (type instanceof JavaType.FullyQualified && !(type instanceof JavaType.Unknown)) { return (JavaType.FullyQualified) type; } return null;