mybatis / mybatis-3

MyBatis SQL mapper framework for Java
http://mybatis.github.io/mybatis-3/
Apache License 2.0
19.72k stars 12.82k forks source link

Fix scanSuperTypes function to return Object Class instead of generic types #3150

Closed yuanjin5 closed 5 months ago

yuanjin5 commented 5 months ago

Fix scanSuperTypes function to return Object Class instead of generic types

Unit Test Code

@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]);
}

Expected :class java.lang.Object Actual: F

coveralls commented 5 months ago

Coverage Status

coverage: 87.179% (+0.01%) from 87.168% when pulling 8fb229ef382dcb64e56c5ceccecbf081ddedc761 on yuanjin5:fixbug into acc10862f71cbe716e48a03ad76dedb32b256d7d on mybatis:master.

harawata commented 5 months ago

Thank you, @yuanjin5 !

Although this is technically correct, it should not affect real projects. i.e. Level2Mapper#selectMap() should be used instead of Level1Mapper#selectMap().