Skip to content

Commit 287764e

Browse files
committed
Added a test case ensures nested ParameterizedType equality
1 parent 9777d90 commit 287764e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/test/java/org/apache/ibatis/reflection/TypeParameterResolverTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Date;
2929
import java.util.List;
3030
import java.util.Map;
31+
import java.util.Map.Entry;
3132
import java.util.concurrent.ExecutorService;
3233
import java.util.concurrent.Executors;
3334
import java.util.concurrent.Future;
@@ -588,4 +589,21 @@ public List<Integer> m() {
588589
}
589590
}
590591

592+
@Test
593+
void shouldParameterizedTypesWithOwnerTypeBeEqual() throws Exception {
594+
class Clazz {
595+
@SuppressWarnings("unused")
596+
public Entry<String, Integer> entry() {
597+
return null;
598+
}
599+
}
600+
601+
Type typeJdk = Clazz.class.getMethod("entry").getGenericReturnType();
602+
603+
Class<?> clazz = Level2Mapper.class;
604+
Method method = clazz.getMethod("selectEntry");
605+
Type typeMybatis = TypeParameterResolver.resolveReturnType(method, clazz);
606+
607+
assertEquals(typeMybatis, typeJdk);
608+
}
591609
}

src/test/java/org/apache/ibatis/reflection/typeparam/Level0Mapper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717

1818
import java.util.List;
1919
import java.util.Map;
20+
import java.util.Map.Entry;
2021

2122
public interface Level0Mapper<L, M, N> {
2223

@@ -46,6 +47,8 @@ public interface Level0Mapper<L, M, N> {
4647

4748
Map<N, M> selectMap();
4849

50+
Entry<N, M> selectEntry();
51+
4952
N[] selectArray(List<N>[] param);
5053

5154
N[][] selectArrayOfArray();

0 commit comments

Comments
 (0)