diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/assignment/WrapperForCollectionsAndMaps.java b/processor/src/main/java/org/mapstruct/ap/internal/model/assignment/WrapperForCollectionsAndMaps.java index 512012bba..f286a45f0 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/assignment/WrapperForCollectionsAndMaps.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/assignment/WrapperForCollectionsAndMaps.java @@ -72,8 +72,7 @@ public class WrapperForCollectionsAndMaps extends AssignmentWrapper { public Set getImportTypes() { Set imported = new HashSet(); imported.addAll( super.getImportTypes() ); - imported.add( nullCheckLocalVarType ); - imported.addAll( nullCheckLocalVarType.getTypeParameters() ); + imported.addAll( nullCheckLocalVarType.getImportTypes() ); return imported; } diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/GenericHolder.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/GenericHolder.java new file mode 100644 index 000000000..7d5dd28d6 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/GenericHolder.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._1164; + +/** + * @author Filip Hrisafov + */ +class GenericHolder { + + private T value; + + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Issue1164Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Issue1164Test.java new file mode 100644 index 000000000..fd2990b1b --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Issue1164Test.java @@ -0,0 +1,43 @@ +/** + * 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._1164; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mapstruct.ap.testutil.IssueKey; +import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; + +/** + * @author Filip Hrisafov + */ +@WithClasses( { + Source.class, + Target.class, + GenericHolder.class, + SourceTargetMapper.class +} ) +@RunWith(AnnotationProcessorTestRunner.class) +@IssueKey( "1164" ) +public class Issue1164Test { + + @Test + public void shouldCompile() { + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Source.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Source.java new file mode 100644 index 000000000..e59304c77 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Source.java @@ -0,0 +1,59 @@ +/** + * 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._1164; + +import java.util.List; +import java.util.Map; + +/** + * @author Filip Hrisafov + */ +class Source { + + public static class SourceNested { + } + + private List> nestedLists; + private Map> nestedMaps; + private GenericHolder> genericHolder; + + public List> getNestedLists() { + return nestedLists; + } + + public void setNestedLists(List> nestedLists) { + this.nestedLists = nestedLists; + } + + public Map> getNestedMaps() { + return nestedMaps; + } + + public void setNestedMaps(Map> nestedMaps) { + this.nestedMaps = nestedMaps; + } + + public GenericHolder> getGenericHolder() { + return genericHolder; + } + + public void setGenericHolder(GenericHolder> genericHolder) { + this.genericHolder = genericHolder; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/SourceTargetMapper.java new file mode 100644 index 000000000..9761dfa01 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/SourceTargetMapper.java @@ -0,0 +1,47 @@ +/** + * 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._1164; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.mapstruct.Mapper; + +/** + * @author Filip Hrisafov + */ +@Mapper +public abstract class SourceTargetMapper { + + public abstract Target map(Source source); + + protected List> mapLists(List> lists) { + return new ArrayList>(); + } + + protected Map> map(Map> map) { + return new HashMap>(); + } + + protected GenericHolder> map(GenericHolder> genericHolder) { + return new GenericHolder>(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Target.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Target.java new file mode 100644 index 000000000..c80a8ecc2 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1164/Target.java @@ -0,0 +1,65 @@ +/** + * 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._1164; + +import java.util.List; +import java.util.Map; + +/** + * @author Filip Hrisafov + */ +class Target { + + public static class TargetNested { + } + + public static class MapNested { + } + + public static class GenericNested { + } + + private List> nestedLists; + private Map> nestedMaps; + private GenericHolder> genericHolder; + + public List> getNestedLists() { + return nestedLists; + } + + public void setNestedLists(List> nestedLists) { + this.nestedLists = nestedLists; + } + + public Map> getNestedMaps() { + return nestedMaps; + } + + public void setNestedMaps(Map> nestedMaps) { + this.nestedMaps = nestedMaps; + } + + public GenericHolder> getGenericHolder() { + return genericHolder; + } + + public void setGenericHolder(GenericHolder> genericHolder) { + this.genericHolder = genericHolder; + } +}