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

Fix introspection for abstract classes (#10889) #11268

Open
wants to merge 1 commit into
base: 4.7.x
Choose a base branch
from

Conversation

rorueda
Copy link
Contributor

@rorueda rorueda commented Oct 22, 2024

Ignore constructors for abstract classes, so the introspection is written as not buildable and the instantiation methods in the introspection are not overridden (trying to call a constructor for an abstract class).

Ignore constructors for abstract classes, so the introspection is
written as not buildable and the instantiation methods in the
introspection are not overridden (trying to call a constructor for an
abstract class).
@dstepanov
Copy link
Contributor

Doesn't look like a correct fix. This should be fixed in IntrospectedTypeElementVisitor

@graemerocher
Copy link
Contributor

yes this fix is not in the correct place, though the tests add value

@rorueda
Copy link
Contributor Author

rorueda commented Oct 24, 2024

Thanks for the pointers, @dstepanov. I'll look into it.

Should the abstract verification below be removed in favor of the fix on IntrospectedTypeElementVisitor? I was unsure of the semantic of getDefaultConstructor, and because of this, I ended up thinking it was to consider only constructors that can be directly called.

private Optional<MethodElement> possibleDefaultEmptyConstructor() {
List<ConstructorNode> constructors = classNode.getDeclaredConstructors();
if (CollectionUtils.isEmpty(constructors) && !classNode.isAbstract() && !classNode.isEnum()) {
// empty default constructor
return createMethodElement(new ConstructorNode(Modifier.PUBLIC, new BlockStatement()));
}
return Optional.empty();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants