#3769·mybatis-3

ParamNameResolver.getType() returns wrong types when special parameters shift indices

Author: harrisleeshCreated Sep 3, 2026Updated Sep 3, 2026

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:

  1. Sole-parameter type lookup uses index 0. For List<User> select(RowBounds rb, Wrapper<Integer> param), names contains only the actual parameter (at key 1), but the type map is populated from actualParamTypes[0] — the RowBounds type — instead of actualParamTypes[names.firstKey()].

  2. paramN resolution treats N as a parameter index. getType("param1") computes paramIndex = 0 and calls names.get(0) — but names keys are declaration indices, so for (RowBounds, X) the map is {1: "arg0"} and names.get(0) returns null, failing to resolve param1 although the generic name paramN is positional among the actual parameters.

Steps to reproduce

java
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> type

Expected 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.