mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#551, fix for isAssignable problem in oracle_java_6
This commit is contained in:
parent
300d7824c4
commit
28ebf763cd
@ -47,6 +47,7 @@ import org.mapstruct.ap.model.source.selector.MethodSelectors;
|
||||
import org.mapstruct.ap.model.source.selector.SelectionCriteria;
|
||||
import org.mapstruct.ap.util.FormattingMessager;
|
||||
import org.mapstruct.ap.util.Message;
|
||||
import org.mapstruct.ap.util.SpecificCompilerWorkarounds;
|
||||
import org.mapstruct.ap.util.Strings;
|
||||
|
||||
/**
|
||||
@ -551,7 +552,7 @@ public class MappingResolverImpl implements MappingResolver {
|
||||
? typeFactory.getType( Object.class ).getTypeMirror()
|
||||
: targetType.getTypeParameters().get( 0 ).getTypeMirror();
|
||||
|
||||
return typeUtils.isAssignable( sourceElementType, targetElementType );
|
||||
return SpecificCompilerWorkarounds.isAssignable( typeUtils, sourceElementType, targetElementType );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,6 +34,26 @@ public class SpecificCompilerWorkarounds {
|
||||
|
||||
private SpecificCompilerWorkarounds() { }
|
||||
|
||||
/**
|
||||
* Tests whether one type is assignable to another.
|
||||
*
|
||||
* <p>
|
||||
* Work-around for a bug most likely related to problem solved with {@link #isSubType}
|
||||
*
|
||||
* @param types the type utils
|
||||
* @param t1 the first type
|
||||
* @param t2 the second type
|
||||
* @return {@code true} if and only if the first type is assignable to the second
|
||||
* @throws IllegalArgumentException if given an executable or package type
|
||||
*/
|
||||
public static boolean isAssignable(Types types, TypeMirror t1, TypeMirror t2) {
|
||||
if ( t1.getKind() == TypeKind.VOID ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return types.isAssignable( erasure( types, t1 ), erasure( types, t2 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether one type is a subtype of another. Any type is considered to be a subtype of itself. Also see <a
|
||||
* href="http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html">JLS section 4.10, Subtyping</a>.
|
||||
|
Loading…
x
Reference in New Issue
Block a user