Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
@@ -0,0 +1,13 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.bugs._3786;

import org.mapstruct.Mapper;

@Mapper
public interface ErroneousByteArrayMapper {
byte[] map( String something );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.bugs._3786;

import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.ProcessorTest;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult;
import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic;
import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome;

/**
* @author Ben Zegveld
*/
@IssueKey( "3786" )
public class Issue3786Test {

@WithClasses( ErroneousByteArrayMapper.class )
@ProcessorTest
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(
type = ErroneousByteArrayMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 12,
message = "Can't generate mapping method from non-iterable type to array."
)
}
)
void byteArrayReturnTypeShouldGiveInaccessibleContructorError() {
}
}
Loading