From 36707354ff26da3dc11b7b356d2bde80f846ba45 Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Tue, 19 Nov 2024 19:30:36 -0800 Subject: [PATCH] Fix crash with void return type --- .../java/com/ibm/wala/types/generics/TypeSignature.java | 3 +-- .../ibm/wala/types/generics/MethodTypeSignatureTest.java | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/ibm/wala/types/generics/TypeSignature.java b/core/src/main/java/com/ibm/wala/types/generics/TypeSignature.java index 6e9c7a3d34..a868f04c00 100644 --- a/core/src/main/java/com/ibm/wala/types/generics/TypeSignature.java +++ b/core/src/main/java/com/ibm/wala/types/generics/TypeSignature.java @@ -44,8 +44,7 @@ public static TypeSignature make(String s) throws IllegalArgumentException { assert !s.isEmpty(); switch (s.charAt(0)) { case TypeReference.VoidTypeCode: - Assertions.UNREACHABLE(); - return null; + return BaseType.VOID; case TypeReference.BooleanTypeCode: return BaseType.BOOLEAN; case TypeReference.ByteTypeCode: diff --git a/core/src/test/java/com/ibm/wala/types/generics/MethodTypeSignatureTest.java b/core/src/test/java/com/ibm/wala/types/generics/MethodTypeSignatureTest.java index 6830779794..76e913c15c 100644 --- a/core/src/test/java/com/ibm/wala/types/generics/MethodTypeSignatureTest.java +++ b/core/src/test/java/com/ibm/wala/types/generics/MethodTypeSignatureTest.java @@ -16,4 +16,11 @@ void getArguments() { MethodTypeSignature.make("(I)V").getArguments(), arrayContaining(is(TypeSignature.make("I")))); } + + @Test + void getVoidReturn() { + assertThat( + MethodTypeSignature.make("(I)V").getReturnType(), + is(TypeSignature.make("V"))); + } }