Skip to content

Commit

Permalink
Fix compilation on K.CompilationUnit.service (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Feb 6, 2024
1 parent 74384ac commit bce277f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/openrewrite/kotlin/tree/K.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public K.CompilationUnit withStatements(List<JRightPadded<Statement>> statements

@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 @@ -356,7 +356,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 bce277f

Please sign in to comment.