Skip to content

ResolvableType for a raw type is not assignable to generic types of the same class [SPR-14648] #19214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Aug 31, 2016 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Oliver Drotbohm opened SPR-14648 and commented

This test case fails for me and I think it shouldn't as a concrete generic type should always be assignable to a raw variant of it:

public class RawTypeAssignmentTests {

	@Test
	public void rawTypeShouldBeassignable() throws Exception {

		// That works.
		Collection value = someMethod();
		
		// So that should, too.
		ResolvableType fromClass = ResolvableType.forClass(Collection.class);
		ResolvableType fromReturnType = ResolvableType.forMethodReturnType(RawTypeAssignmentTests.class.getMethod("someMethod"));

		assertThat(fromClass.isAssignableFrom(fromReturnType), is(true));
	}

	public Collection<?> someMethod() {
		return Collections.emptyList();
	}
}

Affects: 4.2.7, 4.3.2, 5.0 M1

Issue Links:

  • DATAREST-881 ResourceProcessor is not invoked if RepositoryEntityController does not return a subtype of Resources ("is depended on by")

Backported to: 4.2.8

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

The snippet above should be using ResolvableType.forRawClass(Class), then it should indeed be working. However, it is only actually working with ResolvableType.isAssignableFrom(Class) then, not with ResolvableType.isAssignableFrom(ResolvableType). I've fixed that gap for 4.3.3 / 4.2.8.

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3.3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants