mapstruct/mapstruct — pull request #282 by sjaakd (2014-08-15 22:35:23+00:00)
Title: #277 fixing faulty match check in built-in methods on return/target type...

....

The check was carried out in the wrong direction. Iso carrying out if a return type is assignable to a target type, MapStruct checked the other way around (target type assignable to return type).

In fixing, this poses a problem for a typed variable, e.g. ` T jaxbElemToValue( JAXBElement element )`. The erasure of the return type is an Object, which is never assignable to, lets say T being a String.

Therefore to additional checks have been added on the assumption that a a Typed variable erasure is an java.lang.Object.

So the full check now is:
```java
if ( getReturnType().erasure().isAssignableTo( targetType.erasure() )
&& sourceType.erasure().isAssignableTo( getParameter().getType().erasure() ) ) {
return doTypeVarsMatch( sourceType, targetType );
}
if ( getReturnType().erasure().getFullyQualifiedName().equals( "java.lang.Object" )
&& sourceType.erasure().isAssignableTo( getParameter().getType().erasure() ) ) {
// return type could be a type parameter T
return doTypeVarsMatch( sourceType, targetType );
}
if ( getReturnType().erasure().isAssignableTo( targetType.erasure() )
&& getParameter().getType().erasure().getFullyQualifiedName().equals( "java.lang.Object" ) ) {
// parameter type could be a type parameter T
return doTypeVarsMatch( sourceType, targetType );
}
return false;
```
Perhaps there are more elegant ways to achieve this than a String equals check on the FQN.