Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArC - custom error message when kotlin List used with All qualifier #24795

Merged
merged 1 commit into from
Apr 6, 2022
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 @@ -441,9 +441,22 @@ public ObserverRegistrationPhaseBuildItem registerSyntheticObservers(BeanRegistr
// Note that at this point we can be sure that the required type is List<>
Type typeParam = injectionPoint.getType().asParameterizedType().arguments().get(0);
if (typeParam.kind() == Type.Kind.WILDCARD_TYPE) {
validationErrors.produce(new ValidationErrorBuildItem(
new DefinitionException(
"Wildcard is not a legal type argument for " + injectionPoint.getTargetInfo())));
ClassInfo declaringClass;
if (injectionPoint.isField()) {
declaringClass = injectionPoint.getTarget().asField().declaringClass();
} else {
declaringClass = injectionPoint.getTarget().asMethod().declaringClass();
}
if (declaringClass.classAnnotation(DotNames.KOTLIN_METADATA_ANNOTATION) != null) {
validationErrors.produce(new ValidationErrorBuildItem(
new DefinitionException(
"kotlin.collections.List cannot be used together with the @All qualifier, please use MutableList or java.util.List instead: "
+ injectionPoint.getTargetInfo())));
} else {
validationErrors.produce(new ValidationErrorBuildItem(
new DefinitionException(
"Wildcard is not a legal type argument for " + injectionPoint.getTargetInfo())));
}
} else if (typeParam.kind() == Type.Kind.TYPE_VARIABLE) {
validationErrors.produce(new ValidationErrorBuildItem(new DefinitionException(
"Type variable is not a legal type argument for " + injectionPoint.getTargetInfo())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public final class DotNames {
public static final DotName IDENTIFIED = create(Identified.class);
public static final DotName INSTANCE_HANDLE = create(InstanceHandle.class);
public static final DotName NO_CLASS_INTERCEPTORS = create(NoClassInterceptors.class);
public static final DotName DEPRECATED = create(Deprecated.class);
public static final DotName KOTLIN_METADATA_ANNOTATION = create("kotlin.Metadata");

public static final DotName BOOLEAN = create(Boolean.class);
public static final DotName BYTE = create(Byte.class);
Expand All @@ -139,8 +141,6 @@ public final class DotNames {
public static final DotName SHORT = create(Short.class);
public static final DotName STRING = create(String.class);

public static final DotName DEPRECATED = create(Deprecated.class);

private DotNames() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public class SubclassGenerator extends AbstractGenerator {
private static final DotName JAVA_LANG_THROWABLE = DotNames.create(Throwable.class.getName());
private static final DotName JAVA_LANG_EXCEPTION = DotNames.create(Exception.class.getName());
private static final DotName JAVA_LANG_RUNTIME_EXCEPTION = DotNames.create(RuntimeException.class.getName());
private static final DotName KOTLIN_METADATA_ANNOTATION = DotNames.create("kotlin.Metadata");

static final String SUBCLASS_SUFFIX = "_Subclass";
static final String DESTROY_METHOD_NAME = "arc$destroy";
Expand Down Expand Up @@ -750,7 +749,7 @@ private void createInterceptedMethod(ClassOutput classOutput, BeanInfo bean, Met
// catch exceptions declared on the original method
boolean addCatchRuntimeException = true;
boolean addCatchException = true;
boolean isKotlin = method.declaringClass().classAnnotation(KOTLIN_METADATA_ANNOTATION) != null;
boolean isKotlin = method.declaringClass().classAnnotation(DotNames.KOTLIN_METADATA_ANNOTATION) != null;
Set<DotName> declaredExceptions = new LinkedHashSet<>(method.exceptions().size());
for (Type declaredException : method.exceptions()) {
declaredExceptions.add(declaredException.name());
Expand Down