Skip to content

Commit

Permalink
Merge 8fb229e into 46cd8e6
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanjin5 committed Apr 28, 2024
2 parents 46cd8e6 + 8fb229e commit e642213
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -206,7 +206,8 @@ private static Type scanSuperTypes(TypeVariable<?> typeVar, Type srcType, Class<
if (declaringClass == parentAsClass) {
for (int i = 0; i < parentTypeVars.length; i++) {
if (typeVar.equals(parentTypeVars[i])) {
return parentAsType.getActualTypeArguments()[i];
Type actualType = parentAsType.getActualTypeArguments()[i];
return actualType instanceof TypeVariable<?> ? Object.class : actualType;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -261,6 +261,19 @@ void testReturn_Lv2WildcardList() throws Exception {
assertEquals(String.class, wildcard.getUpperBounds()[0]);
}

@Test
void testReturn_LV1Map() throws Exception {
Class<?> clazz = Level1Mapper.class;
Method method = clazz.getMethod("selectMap");
Type result = TypeParameterResolver.resolveReturnType(method, clazz);
assertTrue(result instanceof ParameterizedType);
ParameterizedType paramType = (ParameterizedType) result;
assertEquals(Map.class, paramType.getRawType());
assertEquals(2, paramType.getActualTypeArguments().length);
assertEquals(String.class, paramType.getActualTypeArguments()[0]);
assertEquals(Object.class, paramType.getActualTypeArguments()[1]);
}

@Test
void testReturn_LV2Map() throws Exception {
Class<?> clazz = Level2Mapper.class;
Expand Down

0 comments on commit e642213

Please sign in to comment.