Skip to content

Commit

Permalink
Fix compilation around use of service
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Feb 6, 2024
1 parent 9f38bee commit 8a6d7e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/openrewrite/javascript/tree/JS.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public JavaSourceFile withPackageDeclaration(Package pkg) {

@Override
@SuppressWarnings("unchecked")
public <S> S service(Class<S> service) {
public <S, T extends S> T service(Class<S> service) {
String serviceName = service.getName();
try {
Class<S> serviceClass;
Expand All @@ -217,7 +217,7 @@ public <S> S service(Class<S> service) {
} else {
return JavaSourceFile.super.service(service);
}
return serviceClass.getConstructor().newInstance();
return (T) serviceClass.getConstructor().newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 8a6d7e8

Please sign in to comment.