Repository navigation
Fix untyped field accesses flagged by stricter type validation - #1468
Merged
Merged
Conversation
openrewrite/rewrite#10034 makes RewriteTest's type check flag a field access that has no type. Here that surfaced one recipe and three test inputs: - AddTableGenerator's templates had no classpath, so the inserted `@javax.persistence.TableGenerator` and `GenerationType.TABLE` were untyped. With them typed, RemoveImport counts the fully qualified `GenerationType` reference as a use, so the strategy is now written as `GenerationType.TABLE` with an import. - AdoptLombokSetterMethodNamesTest declared `Foo` but assigned `this.foo`. - AddScopeToInjectedClassTest used `ElementType.Type` rather than `TYPE`. - BouncyCastleApiTest used `sha2_128f`, which bcprov-jdk15on 1.70 does not have; it has `sha256_128f`.
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.
openrewrite/rewrite#10034 makes the
RewriteTesttype check flag a field access with no type. Run against this repository, it fails 7 of 2,998 tests. Each failure is a real defect, and this fixes them so the repository doesn't go red when that change reacheslatest.integration. The fixes also pass against the current rewrite release, so this can merge first.AddTableGenerator: its two templates had no classpath, so the inserted@javax.persistence.TableGeneratorandGenerationType.TABLEwere untyped. They now parse againstjavax.persistence-api-2.2. Once typed,RemoveImporttreats the fully qualifiedjavax.persistence.GenerationTypereference as a use and keeps the import, so the recipe now writesGenerationType.TABLEand adds the import. That changes the expected output inAddTableGeneratorTest.AdoptLombokSetterMethodNamesTest:noBoxing1/noBoxing2declaredFoobut assignedthis.foo, so they never exercised boxing. With the name fixed, the recipe still leaves them alone.AddScopeToInjectedClassTest:ElementType.Typeis not a constant, so it is nowTYPE. The twodependsOnstubs also gained their missingjava.lang.annotationimport.BouncyCastleApiTest: bcprov-jdk15on 1.70 hasSPHINCSPlusParameters.sha256_128f, notsha2_128f.Verified by running
./gradlew testwith rewrite#10034's compiledFindMissingTypes,Assertions,ExtractFieldandReplaceStringLiteralWithConstantclasses first on the test classpath: 2,998 tests and 0 failures, where without these fixes 7 failed. The four changed test classes also pass without that swap, against the snapshot this build resolves.