use of javax.lang.model.type.PrimitiveType in project buck by facebook.
the class TreeBackedTypesTest method testIsNotSameTypeDifferentTypes.
@Test
public void testIsNotSameTypeDifferentTypes() throws IOException {
initCompiler();
PrimitiveType intType = types.getPrimitiveType(TypeKind.INT);
ArrayType intArrayType = types.getArrayType(intType);
assertNotSameType(intType, intArrayType);
}
use of javax.lang.model.type.PrimitiveType in project buck by facebook.
the class TreeBackedTypesTest method testIsSameTypePrimitiveType.
@Test
public void testIsSameTypePrimitiveType() throws IOException {
initCompiler();
for (TypeKind typeKind : TypeKind.values()) {
if (typeKind.isPrimitive()) {
PrimitiveType primitiveType = types.getPrimitiveType(typeKind);
PrimitiveType primitiveType2 = types.getPrimitiveType(typeKind);
assertSameType(primitiveType, primitiveType2);
}
}
}
use of javax.lang.model.type.PrimitiveType in project j2objc by google.
the class JdtTypes method resolvePrimitiveType.
private void resolvePrimitiveType(AST ast, TypeKind kind, String pName, String cName) {
PrimitiveType primitiveType = (PrimitiveType) BindingConverter.getType(ast.resolveWellKnownType(pName));
TypeElement classElement = BindingConverter.getTypeElement(ast.resolveWellKnownType(cName));
primitiveTypes.put(kind, primitiveType);
boxedClasses.put(kind, classElement);
unboxedTypes.put(classElement, primitiveType);
}
use of javax.lang.model.type.PrimitiveType in project mapstruct by mapstruct.
the class TypeFactory method getWrappedType.
public Type getWrappedType(Type type) {
Type result = type;
if (type.isPrimitive()) {
PrimitiveType typeMirror = (PrimitiveType) type.getTypeMirror();
result = getType(typeUtils.boxedClass(typeMirror));
}
return result;
}
use of javax.lang.model.type.PrimitiveType in project mapstruct by mapstruct.
the class MethodMatcher method matchResultType.
private boolean matchResultType(Type resultType, Map<TypeVariable, TypeMirror> genericTypesMap) {
Type candidateResultType = candidateMethod.getResultType();
if (!isJavaLangObject(candidateResultType.getTypeMirror()) && !candidateResultType.isVoid()) {
final Assignability visitedAssignability;
if (candidateMethod.getReturnType().isVoid()) {
// for void-methods, the result-type of the candidate needs to be assignable from the given result type
visitedAssignability = Assignability.VISITED_ASSIGNABLE_FROM;
} else {
// for non-void methods, the result-type of the candidate needs to be assignable to the given result
// type
visitedAssignability = Assignability.VISITED_ASSIGNABLE_TO;
}
TypeMatcher returnTypeMatcher = new TypeMatcher(visitedAssignability, genericTypesMap);
if (!returnTypeMatcher.visit(candidateResultType.getTypeMirror(), resultType.getTypeMirror())) {
if (resultType.isPrimitive()) {
TypeMirror boxedType = typeUtils.boxedClass((PrimitiveType) resultType.getTypeMirror()).asType();
TypeMatcher boxedReturnTypeMatcher = new TypeMatcher(visitedAssignability, genericTypesMap);
if (!boxedReturnTypeMatcher.visit(candidateResultType.getTypeMirror(), boxedType)) {
return false;
}
} else if (candidateResultType.getTypeMirror().getKind().isPrimitive()) {
TypeMirror boxedCandidateReturnType = typeUtils.boxedClass((PrimitiveType) candidateResultType.getTypeMirror()).asType();
TypeMatcher boxedReturnTypeMatcher = new TypeMatcher(visitedAssignability, genericTypesMap);
if (!boxedReturnTypeMatcher.visit(boxedCandidateReturnType, resultType.getTypeMirror())) {
return false;
}
} else {
return false;
}
}
}
return true;
}
Aggregations