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

review: fix: Fix return type of setParent #4099

Merged
merged 5 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -208,7 +208,7 @@ enum UNIT_TYPE {

@Override
@UnsettableProperty
<E extends CtElement> E setParent(E parent);
<E extends CtElement, P extends CtElement> E setParent(P parent);

@Override
@UnsettableProperty
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/reflect/declaration/CtElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ <E extends CtElement> List<E> getAnnotatedChildren(
* @param parent
* parent reference.
*/
<E extends CtElement> E setParent(E parent);
<E extends CtElement, P extends CtElement> E setParent(P parent);

/**
* Tells if this parent has been initialized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public <C extends CtTypeAccess<A>> C setAccessedType(CtTypeReference<A> accessed

@Override
public CtTypeReference<Void> getType() {
return (CtTypeReference<Void>) getFactory().Type().VOID_PRIMITIVE.clone().<CtTypeAccess>setParent(this);
return getFactory().Type().VOID_PRIMITIVE.clone().setParent(this);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Case and point in small amount of breakage: this was the only part of the entire Spoon codebase that needed to change, apart from the directly affected method headers.

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public CtElement getParent() throws ParentNotInitializedException {

@Override
@UnsettableProperty
public <E extends CtElement> E setParent(E parent) {
public <E extends CtElement, P extends CtElement> E setParent(P parent) {
return (E) this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public CtElement getParent() throws ParentNotInitializedException {
}

@Override
public <E extends CtElement> E setParent(E parent) {
public <E extends CtElement, P extends CtElement> E setParent(P parent) {
this.parent = parent;
return (E) this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ public CtModule clone() {

@Override
@DerivedProperty
public <T extends CtElement> T setParent(T parent) {
return (T) this;
public <E extends CtElement, P extends CtElement> E setParent(P parent) {
return (E) this;
}

@Override
Expand Down