Skip declaration-site variance for invariant storage - #1007
Draft
martinfrancois wants to merge 1 commit into
Draft
Skip declaration-site variance for invariant storage#1007martinfrancois wants to merge 1 commit into
martinfrancois wants to merge 1 commit into
Conversation
4 tasks
martinfrancois
force-pushed
the
agent/repro-declaration-site-variance-invariant-field
branch
2 times, most recently
from
August 16, 2026 02:53
293c634 to
f5bb241
Compare
martinfrancois
force-pushed
the
agent/repro-declaration-site-variance-invariant-field
branch
from
August 16, 2026 20:17
f5bb241 to
ca9a29f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suggested review order: 11 of 52 (Score: 7.5)
Review first: #990
What's changed?
Leaves a declaration-site type unchanged when the parameter is stored directly in an invariant field or explicitly typed local variable. Parameters remain eligible when their destination already accepts the proposed variance or when an adapter expression is stored instead.
What's your motivation?
Recipe:
org.openrewrite.staticanalysis.CommonDeclarationSiteTypeVariances.I found this by running
org.openrewrite.staticanalysis.CommonDeclarationSiteTypeVariances, which configuresDeclarationSiteTypeVariance, fromorg.openrewrite.recipe:rewrite-static-analysis:2.39.0onConfigResolver.javain Symphony-Trello ata8013f27. I reproduced the same result with the latest released recipe artifact,org.openrewrite.recipe:rewrite-static-analysis:2.41.0. The recipe changed 18 files, and./mvnw -DskipTests compilethen reported four incompatible-type errors.Before
Actual after the recipe
Expected after the recipe
(unchanged)The wildcarded parameter is not assignable to the invariant field. The recipe therefore turns compiling production code into code that does not compile.
Confirmed real-world execution
ConfigResolver.javaata8013f27.martinfrancois/symphony-trello@a8013f27.Anything in particular you'd like reviewers to focus on?
Please review the direct-storage boundary. Tim te Beek preferred this approach: skip variance where direct invariant storage makes it invalid, while retaining valid conversions instead of widening unrelated fields.
Have you considered any alternatives or workarounds?
Widening the destination field would expand the recipe beyond declaration-site parameter variance and change APIs and later uses. Skipping only the invalid parameter conversion keeps the change local.
Any additional context
Pre-existing tests changed: None.
martinfrancois/symphony-trello@a8013f27org.openrewrite.recipe:rewrite-static-analysis:2.39.0org.openrewrite.recipe:rewrite-static-analysis:2.41.0ConfigResolver,TrelloBoardSetup,GitHubConfigurator, andSetupSystemPropertiesDeclarationSiteTypeVarianceTestThis change was prepared with AI assistance. I reviewed the target execution evidence, implementation, tests, and contribution text.
Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv