restored preference for covariant return type if applicable

This commit is contained in:
Juergen Hoeller
2012-02-09 12:24:13 +01:00
parent 35c2869875
commit 0db257cbe3

View File

@@ -142,10 +142,20 @@ public final class Property {
private MethodParameter resolveMethodParameter() {
MethodParameter read = resolveReadMethodParameter();
MethodParameter write = resolveWriteMethodParameter();
if (read == null && write == null) {
throw new IllegalStateException("Property is neither readable nor writeable");
if (write == null) {
if (read == null) {
throw new IllegalStateException("Property is neither readable nor writeable");
}
return read;
}
return (write != null ? write : read);
if (read != null) {
Class<?> readType = read.getParameterType();
Class<?> writeType = write.getParameterType();
if (!writeType.equals(readType) && writeType.isAssignableFrom(readType)) {
return read;
}
}
return write;
}
private MethodParameter resolveReadMethodParameter() {