diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java b/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java index 6fd311338..c668b207f 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java @@ -309,8 +309,8 @@ public class Type extends ModelElement implements Comparable { result.addAll( parameter.getImportTypes() ); } - if ( boundingBase != null ) { - result.addAll( boundingBase.getImportTypes() ); + if ( ( isWildCardExtendsBound() || isWildCardSuperBound() ) && getTypeBound() != null ) { + result.addAll( getTypeBound().getImportTypes() ); } return result; diff --git a/processor/src/main/resources/org/mapstruct/ap/internal/model/common/Type.ftl b/processor/src/main/resources/org/mapstruct/ap/internal/model/common/Type.ftl index 1d63cb320..15fbc47d8 100644 --- a/processor/src/main/resources/org/mapstruct/ap/internal/model/common/Type.ftl +++ b/processor/src/main/resources/org/mapstruct/ap/internal/model/common/Type.ftl @@ -1,3 +1,4 @@ +<#-- @ftlvariable name="" type="org.mapstruct.ap.internal.model.common.Type" --> <#-- diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/Issue543Mapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/Issue543Mapper.java new file mode 100644 index 000000000..798870ced --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/Issue543Mapper.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._543; + +import java.util.List; + +import org.mapstruct.Mapper; +import org.mapstruct.ap.test.bugs._543.dto.Source; +import org.mapstruct.ap.test.bugs._543.dto.Target; + +/** + * @author Filip Hrisafov + */ +@Mapper(uses = { SourceUtil.class }) +public interface Issue543Mapper { + + List map(List source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/Issue543Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/Issue543Test.java new file mode 100644 index 000000000..a1f43a379 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/Issue543Test.java @@ -0,0 +1,45 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._543; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mapstruct.ap.test.bugs._543.dto.Source; +import org.mapstruct.ap.test.bugs._543.dto.Target; +import org.mapstruct.ap.testutil.IssueKey; +import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; + +/** + * @author Filip Hrisafov + */ +@RunWith(AnnotationProcessorTestRunner.class) +@IssueKey("543") +@WithClasses({ + Issue543Mapper.class, + Source.class, + SourceUtil.class, + Target.class +}) +public class Issue543Test { + + @Test + public void shouldCompile() { + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/SourceUtil.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/SourceUtil.java new file mode 100644 index 000000000..7c5808fb8 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/SourceUtil.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._543; + +import org.mapstruct.ap.test.bugs._543.dto.Source; +import org.mapstruct.ap.test.bugs._543.dto.Target; + +/** + * @author Filip Hrisafov + */ +public class SourceUtil { + + private SourceUtil() { + + } + + public static Target from(Source source) { + if ( source == null ) { + return null; + } + return new Target( source.getString() ); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/dto/Source.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/dto/Source.java new file mode 100644 index 000000000..1c6148d5f --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/dto/Source.java @@ -0,0 +1,35 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._543.dto; + +/** + * @author Filip Hrisafov + */ +public class Source { + + private String string; + + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/dto/Target.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/dto/Target.java new file mode 100644 index 000000000..25a423db9 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_543/dto/Target.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._543.dto; + +/** + * @author Filip Hrisafov + */ +public class Target { + + private final String string; + + public Target(String string) { + this.string = string; + } +}