Browse Source

DATACMNS-855 - Fixed generic type lookup in SyntheticParamterizedType.

The translation of the list of actual type parameters into an array now uses the loop index correctly. Previously, it always used the first type parameter.
pull/172/head
Oliver Gierke 10 years ago
parent
commit
f0dbad5185
  1. 2
      src/main/java/org/springframework/data/util/TypeDiscoverer.java
  2. 13
      src/test/java/org/springframework/data/util/ClassTypeInformationUnitTests.java

2
src/main/java/org/springframework/data/util/TypeDiscoverer.java

@ -597,7 +597,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> { @@ -597,7 +597,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
Type[] result = new Type[typeParameters.size()];
for (int i = 0; i < typeParameters.size(); i++) {
result[i] = typeParameters.get(0).getType();
result[i] = typeParameters.get(i).getType();
}
return result;

13
src/test/java/org/springframework/data/util/ClassTypeInformationUnitTests.java

@ -355,6 +355,7 @@ public class ClassTypeInformationUnitTests { @@ -355,6 +355,7 @@ public class ClassTypeInformationUnitTests {
/**
* @see DATACMNS-783
* @see DATACMNS-853
*/
@Test
public void specializesTypeUsingTypeVariableContext() {
@ -366,6 +367,7 @@ public class ClassTypeInformationUnitTests { @@ -366,6 +367,7 @@ public class ClassTypeInformationUnitTests {
assertThat(specialized.getType(), is((Object) Bar.class));
assertThat(specialized.getProperty("field").getType(), is((Object) Character.class));
assertThat(specialized.getProperty("anotherField").getType(), is((Object) Integer.class));
}
/**
@ -575,16 +577,17 @@ public class ClassTypeInformationUnitTests { @@ -575,16 +577,17 @@ public class ClassTypeInformationUnitTests {
static class Leaf {}
static class TypeWithAbstractGenericType<T> {
AbstractBar<T> abstractBar;
static class TypeWithAbstractGenericType<T, S> {
AbstractBar<T, S> abstractBar;
Object object;
}
static class Foo extends TypeWithAbstractGenericType<Character> {}
static class Foo extends TypeWithAbstractGenericType<Character, Integer> {}
static abstract class AbstractBar<T> {}
static abstract class AbstractBar<T, S> {}
static class Bar<T> extends AbstractBar<T> {
static class Bar<T, S> extends AbstractBar<T, S> {
T field;
S anotherField;
}
}

Loading…
Cancel
Save