Skip to content

Commit

Permalink
fix: Model#collectParameters is failed on parameterized type variable
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Nov 16, 2024
1 parent 3607afe commit 1357525
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/java/kiss/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ static synchronized Model of(Type type, Type base) {
return of(collectParameters(base, variable.getGenericDeclaration())[i], base);
}
}

}
}

Expand Down Expand Up @@ -671,7 +672,7 @@ private static Type[] collectParameters(Type clazz, GenericDeclaration target, T
try {
args[i] = Model.of(args[i], base).type;
} catch (ArrayIndexOutOfBoundsException e) {
args[i] = collectParameters(clazz, target)[i];
args[i] = clazz == base ? Object.class : collectParameters(clazz, target)[i];
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/kiss/LogInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

import java.lang.System.Logger.Level;

import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

@Execution(ExecutionMode.SAME_THREAD)
public class LogInitializer {
static {
I.env("*.file", Level.OFF);
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/kiss/LogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

import antibug.CleanRoom;

@Execution(ExecutionMode.SAME_THREAD)
class LogTest extends LogInitializer {

private PrintStream original;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/kiss/core/CollectParametersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ abstract class Definition<E> implements UnaryOperator<E> {
assert types[1] == Object.class;
}

@Test
void parameterizedTypeVariable() throws Exception {
class Definition<E> {
UnaryOperator<E> op;
Expand Down

0 comments on commit 1357525

Please sign in to comment.