Skip to content

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