eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Type inference issue in the spring security/mockito project
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 49
Description
The following is a simplified class [HttpSecurityConfigurationTests.java](https://github.com/spring-projects/spring-security/blob/main/config/src/test/java/org/springframework/security/config/annotation/web/configuration/HttpSecurityConfigurationTests.java) from the spring-security project:
```
public class TestClass {
public static void main(String[] args) {
@SuppressWarnings("unchecked")
ArgumentCaptor.AuthorizationManagerRequestMatcherRegistry> arg = ArgumentCaptor
.forClass(AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry.class);
System.out.println(arg);
}
}
class ArgumentCaptor {
@SuppressWarnings("unused")
private final Class clazz;
private ArgumentCaptor(Class clazz) {
this.clazz = clazz;
}
public static ArgumentCaptor forClass(Class clazz) {
return new ArgumentCaptor<>(clazz);
}
}
class AuthorizeHttpRequestsConfigurer {
public final class AuthorizationManagerRequestMatcherRegistry {
}
}
```
ECJ shows the following error:
```
Type mismatch: cannot convert from ArgumentCaptor to ArgumentCaptor.AuthorizationManagerRequestMatcherRegistry>
```
at line 4.
javac compiles and runs this class.
I am preparing a test and a potential PR.
Contributor guide
Research direction
Start with the simplified TestClass reproducer and compare ECJ's type-inference result with javac. Use config/src/test/java/org/springframework/security/config/annotation/web/configuration/HttpSecurityConfigurationTests.java as the real-world case, then add a regression test showing that the valid ArgumentCaptor assignment compiles without the reported mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100