fix: fixed MirroredTypesException

This commit is contained in:
zaaarf 2023-03-15 12:59:54 +01:00
parent 8fd7006a34
commit 2463dd3e76
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C

View file

@ -15,6 +15,7 @@ import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.*;
import javax.lang.model.type.ExecutableType;
import javax.lang.model.type.MirroredTypesException;
import javax.lang.model.type.TypeMirror;
import javax.tools.Diagnostic;
import javax.tools.FileObject;
@ -407,9 +408,19 @@ public class LilleroProcessor extends AbstractProcessor {
if(injectionCandidates.size() == 1)
injectionTarget = injectionCandidates.get(0);
if(injectorAnn.params().length != 0) {
List<TypeMirror> params = new ArrayList<>();
try {
params.addAll(Arrays.stream(injectorAnn.params())
.map(Class::getCanonicalName)
.map(fqn -> processingEnv.getElementUtils().getTypeElement(fqn).asType())
.collect(Collectors.toList()));
} catch(MirroredTypesException e) {
params.addAll(e.getTypeMirrors());
}
if(params.size() != 0) {
StringBuilder descr = new StringBuilder("(");
for(Class<?> p : injectorAnn.params())
for(TypeMirror p : params)
descr.append(descriptorFromType(TypeName.get(p)));
descr.append(")");
injectionCandidates =