#2704 Fix broken reference to constants within nested enums

This commit is contained in:
Valentin Kulesh 2021-12-26 13:22:05 +03:00 committed by GitHub
parent 0a7b8134d4
commit 42cfa05c40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 1 deletions

View File

@ -6,4 +6,4 @@
-->
<#-- @ftlvariable name="" type="org.mapstruct.ap.internal.model.assignment.EnumConstantWrapper" -->
${ext.targetType.name}.${assignment}
${ext.targetType.createReferenceName()}.${assignment}

View File

@ -0,0 +1,21 @@
/*
* 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._2704;
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.ProcessorTest;
import org.mapstruct.ap.testutil.WithClasses;
/**
* @author Valentin Kulesh
*/
@IssueKey("2704")
@WithClasses({ TestMapper.class, TopLevel.class })
public class Issue2704Test {
@ProcessorTest
public void shouldCompile() {
}
}

View File

@ -0,0 +1,19 @@
/*
* 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._2704;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ap.test.bugs._2704.TopLevel.Target;
/**
* @author Valentin Kulesh
*/
@Mapper(implementationPackage = "")
public interface TestMapper {
@Mapping(target = "e", constant = "VALUE1")
Target test(Object unused);
}

View File

@ -0,0 +1,21 @@
/*
* 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._2704;
/**
* @author Valentin Kulesh
*/
public interface TopLevel {
enum InnerEnum {
VALUE1,
VALUE2,
}
class Target {
public void setE(@SuppressWarnings("unused") InnerEnum e) {
}
}
}