From e5f9bb76b1207711732b843ec228c10f51a9ec64 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 17 Aug 2022 13:34:31 +0200 Subject: [PATCH] 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. --- .../springframework/aot/generate/DefaultGenerationContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/aot/generate/DefaultGenerationContext.java b/spring-core/src/main/java/org/springframework/aot/generate/DefaultGenerationContext.java index 23de9c5b2a..e087d0fef0 100644 --- a/spring-core/src/main/java/org/springframework/aot/generate/DefaultGenerationContext.java +++ b/spring-core/src/main/java/org/springframework/aot/generate/DefaultGenerationContext.java @@ -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); }