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 @@ -26,6 +26,7 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
Expand Down Expand Up @@ -699,7 +700,14 @@ private ConstructorAccessor getConstructorAccessor(Type type) {
method.getExecutable(),
GENERAL_AMBIGUOUS_CONSTRUCTORS,
type,
Strings.join( constructors, ", " )
constructors.stream()
.map( ExecutableElement::getParameters )
.map( ps -> ps.stream()
.map( VariableElement::asType )
.map( String::valueOf )
.collect( Collectors.joining( ", ", type.getName() + "(", ")" ) )
)
.collect( Collectors.joining( ", " ) )
);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public enum Message {
GENERAL_AMBIGUOUS_MAPPING_METHOD( "Ambiguous mapping methods found for mapping %s to %s: %s. See " + FAQ_AMBIGUOUS_URL + " for more info." ),
GENERAL_AMBIGUOUS_FACTORY_METHOD( "Ambiguous factory methods found for creating %s: %s. See " + FAQ_AMBIGUOUS_URL + " for more info." ),
GENERAL_AMBIGUOUS_PRESENCE_CHECK_METHOD( "Ambiguous presence check methods found for checking %s: %s. See " + FAQ_AMBIGUOUS_URL + " for more info." ),
GENERAL_AMBIGUOUS_CONSTRUCTORS( "Ambiguous constructors found for creating %s. Either declare parameterless constructor or annotate the default constructor with an annotation named @Default." ),
GENERAL_AMBIGUOUS_CONSTRUCTORS( "Ambiguous constructors found for creating %s: %s. Either declare parameterless constructor or annotate the default constructor with an annotation named @Default." ),
GENERAL_CONSTRUCTOR_PROPERTIES_NOT_MATCHING_PARAMETERS( "Incorrect @ConstructorProperties for %s. The size of the @ConstructorProperties does not match the number of constructor parameters" ),
GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK( "No dateFormat check is supported for types %s, %s" ),
GENERAL_VALID_DATE( "Given date format \"%s\" is valid.", Diagnostic.Kind.NOTE ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public class ErroneousConstructorTest {
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 17,
message = "Ambiguous constructors found for creating org.mapstruct.ap.test.constructor.erroneous" +
".ErroneousAmbiguousConstructorsMapper.PersonWithMultipleConstructors. Either declare parameterless " +
"constructor or annotate the default constructor with an annotation named @Default."
".ErroneousAmbiguousConstructorsMapper.PersonWithMultipleConstructors: " +
"PersonWithMultipleConstructors(java.lang.String), " +
"PersonWithMultipleConstructors(java.lang.String, int). Either declare parameterless constructor " +
"or annotate the default constructor with an annotation named @Default."
)
})
public void shouldUseMultipleConstructors() {
Expand Down