Browse Source

Declare covariant return type in DefaultGenerationContext.withName()

Prior to this commit, if infrastructure code working directly with an
instance of DefaultGenerationContext invoked withName() on that
instance, the new GenerationContext had to be cast from
GenerationContext to DefaultGenerationContext in order for the
infrastructure to continue working with the DefaultGenerationContext
API -- for example, the writeGeneratedContent() method which is not
defined in the GenerationContext API.

This commit makes use of a covariant return type by declaring that
DefaultGenerationContext.withName() returns a DefaultGenerationContext.
pull/28958/head
Sam Brannen 2 years ago
parent
commit
e5f9bb76b1
  1. 2
      spring-core/src/main/java/org/springframework/aot/generate/DefaultGenerationContext.java

2
spring-core/src/main/java/org/springframework/aot/generate/DefaultGenerationContext.java

@ -115,7 +115,7 @@ public class DefaultGenerationContext implements GenerationContext { @@ -115,7 +115,7 @@ public class DefaultGenerationContext implements GenerationContext {
}
@Override
public GenerationContext withName(String name) {
public DefaultGenerationContext withName(String name) {
return new DefaultGenerationContext(this, name);
}

Loading…
Cancel
Save