[BUG] @Bean factory method with a type variable (<T> Foo<T>) is not a candidate for a parameterized injection point
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- developer-experience, tooling
Research direction
Read SpringCoreUtil.kt functions isEqualOrInheritorBeanType, filterByExactMatch, and filterByBeanPsiType, then trace their use from NativeSearchService.kt in findActiveBeanDeclarations. Compare the plugin lookup with Spring’s fallback behavior for unresolvable generics. Done means tests cover the generic field and the case with a typed bean, with the strict match taking precedence.
Written by the indexing model from the issue text.
Description
Component
Navigation gutter
Problem details
A @Bean factory method with its own type parameter is not found for a parameterized injection point, while Spring injects it.
public class TestGeneric<T> {}
@Configuration
public class DemoConfig {
@Bean
public <T> TestGeneric<T> foo() {
return new TestGeneric<>();
}
}
@Component
public class DemoService {
@Autowired TestGeneric<String> generic; // Spring injects foo
}
- Spring (
AnnotationConfigApplicationContext, spring-context 6.2.14) injectsfoo. - The plugin shows no target for the
genericfield: the bean-dependencies gutter is empty, and the autowiring inspection reads the same lookup (NativeSearchService.findActiveBeans).
Measured with a gutter probe test on main and on both versions of PR #800 (filterByExactMatch + isAssignableFrom): the result is [] everywhere. This is not a regression of #800, the gap is older.
Cause: Spring matches the candidate in its fallback pass. When the strict generic match finds nothing for a single-valued injection point, GenericTypeAwareAutowireCandidateResolver accepts a candidate whose type has unresolvable generics (ResolvableType.hasUnresolvableGenerics()): a raw type or a type variable such as TestGeneric<T>. The plugin has no such pass:
SpringCoreUtil.isEqualOrInheritorBeanType/equalParamsWithBoundcompareTwithStringand reject it;PsiType.isAssignableFromrejects it too, becauseTestGeneric<T>is not assignable toTestGeneric<String>in Java.
Steps to reproduce
- Open the snippet above in a project with Spring Context on the classpath.
- Look at the bean-dependencies gutter of the
genericfield. - Expected: a target
foo(). Actual: no target.
Additional information
Expected behaviour, following Spring:
- run the fallback only when the strict pass finds no candidate;
- accept only candidates with unresolvable generics (type variable or raw return type);
- the strict pass must keep winning: with an additional
@Bean TestGeneric<String> typed(), onlytypedis a candidate.
A test should cover the single field, plus the case where typed() exists next to foo().
Plugin version
main at 65ccf517c (generation 35, unreleased)
IDE name and build
IntelliJ IDEA 2026.2.3 (IU-262)
Build system
IntelliJ
Additional context
- Found during the review of PR #800 (#799). The Spring oracle and the probe test are rows H and X4 of its empirical matrix.
- Related: #799 (generic
@Beansubclass for a parameterized injection point), #749 (inherited generic@Beanfactory in the abstract-component gutter). - Code:
modules/spring-core/.../util/SpringCoreUtil.kt(isEqualOrInheritorBeanType,filterByExactMatch,filterByBeanPsiType),modules/spring-core/.../service/NativeSearchService.kt(findActiveBeanDeclarations).
Created automatically by github-issue-manager skill.
- Dominant language
- Kotlin
- Stars
- 163
- Forks
- 16
- Avg merge
- 5h 35m
- Merged PRs (30d)
- 183
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from explyt/spring-plugin
-
Imported configuration's @Bean methods record the configuration class instead of the return typeOpenin:spring-core
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
explyt/spring-plugin#787 ·
Maintainers usually reply within 1 day
-
in:spring-core native-link
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
explyt/spring-plugin#375 ·
Maintainers usually reply within 1 day
-
in:spring-web inspection
Difficulty 5/5 Over a week Newbie friendliness 38/100
explyt/spring-plugin#815 ·
Maintainers usually reply within 1 day
-
inspection
Difficulty 5/5 Over a week Newbie friendliness 35/100
explyt/spring-plugin#814 ·
Maintainers usually reply within 1 day
-
in:spring-core inspection
Difficulty 5/5 Over a week Newbie friendliness 35/100
explyt/spring-plugin#813 ·
Maintainers usually reply within 1 day
All issues in explyt/spring-plugin
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
react/react-native#59693 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Itch.io full searchOpen
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Droid-Deck/DroidDeck#1852 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
pengchujin/aerial-tv#989 · 3 comments ·
Maintainers usually reply within 1 day