ParamNameResolver.getType() returns wrong types when special parameters shift indices
MyBatis version
master (c5e06b1)
Description
Two related index bugs in ParamNameResolver when the mapper method has special parameters (RowBounds or ResultHandler), which are excluded from names but still occupy positions in actualParamTypes:
Sole-parameter type lookup uses index 0. For
List<User> select(RowBounds rb, Wrapper<Integer> param),namescontains only the actual parameter (at key 1), but the type map is populated fromactualParamTypes[0]— theRowBoundstype — instead ofactualParamTypes[names.firstKey()].paramNresolution treats N as a parameter index.getType("param1")computesparamIndex = 0and callsnames.get(0)— butnameskeys are declaration indices, so for(RowBounds, X)the map is{1: "arg0"}andnames.get(0)returnsnull, failing to resolveparam1although the generic nameparamNis positional among the actual parameters.
Steps to reproduce
Method m = Mapper.class.getMethod("select", RowBounds.class, Wrapper.class);
ParamNameResolver resolver = new ParamNameResolver(config, m);
resolver.getType("param1"); // empty / wrong — expected the Wrapper<Integer> typeExpected result
getType resolves the sole parameter's type from its actual declaration index, and paramN is interpreted positionally over the actual (non-special) parameters. I will submit a PR with failing tests and a fix.
Source: mybatis/mybatis-3