Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#3786: Added new error message for non-iterable to array mapping.
  • Loading branch information
Ben Zegveld authored and Ben Zegveld committed Dec 22, 2024
commit 9b4167865b9ca99ea1d4d7aef092d54587cad5fb
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ private boolean checkParameterAndReturnType(ExecutableElement method, List<Param
return false;
}

if ( !parameterType.isIterableOrStreamType() && resultType.isArrayType() ) {
messager.printMessage( method, Message.RETRIEVAL_NON_ITERABLE_TO_ARRAY );
return false;
}

if ( parameterType.isPrimitive() ) {
messager.printMessage( method, Message.RETRIEVAL_PRIMITIVE_PARAMETER );
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public enum Message {
RETRIEVAL_ITERABLE_TO_NON_ITERABLE( "Can't generate mapping method from iterable type from java stdlib to non-iterable type." ),
RETRIEVAL_MAPPING_HAS_TARGET_TYPE_PARAMETER( "Can't generate mapping method that has a parameter annotated with @TargetType." ),
RETRIEVAL_NON_ITERABLE_TO_ITERABLE( "Can't generate mapping method from non-iterable type to iterable type from java stdlib." ),
RETRIEVAL_NON_ITERABLE_TO_ARRAY( "Can't generate mapping method from non-iterable type to array." ),
RETRIEVAL_PRIMITIVE_PARAMETER( "Can't generate mapping method with primitive parameter type." ),
RETRIEVAL_PRIMITIVE_RETURN( "Can't generate mapping method with primitive return type." ),
RETRIEVAL_TYPE_VAR_SOURCE( "Can't generate mapping method for a generic type variable source." ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Issue3786Test {
type = ErroneousByteArrayMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 12,
message = "byte[] does not have an accessible constructor."
message = "Can't generate mapping method from non-iterable type to array."
)
}
)
Expand Down