Repository navigation
Check contract member accessibility for referenced builders (#313) - #314
Merged
AndreasIgel merged 4 commits intoOct 1, 2026
Merged
Conversation
…s#313) The contract checks in resolveByBuilderContract verified member presence only: a private or cross-package package-private ctor(T), B() or build() passed the contract but produced uncompilable generated code. The three JavaLangAnalyser helpers now filter members through isMemberAccessibleFromBuilderPackage before matching, consistent with the member checks used elsewhere. The resolver's refresh now also tracks builderPackage, not just the configuration: resolution results are cached per referenced type, and the accessible-member set depends on the generated builder's package, which may differ between targets sharing a configuration. Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Replace the two loosely related cache markers (cachedConfiguration, cachedBuilderPackage) with a record compared as a unit, so the invalidation condition reads as 'the inputs are unchanged'. Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
The field holds the inputs the resolution cache was built under, so the cached marker belongs in the name. Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
|
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.



Issues: resolves #313 · sub-task of #301 · follow-up to #308 (#311)
Problem
resolveByBuilderContractverified the referenced builder's contract by presence only: a private or cross-package package-privatector(T), no-argB()orbuild()satisfied the contract, but generated consumer code calls these members — producing uncompilable code whenever they were not accessible from the generated builder's package.Fix
The three contract helpers in
JavaLangAnalyser(hasConstructorAccepting,hasEmptyConstructor,hasBuildMethodReturning) now filter member streams throughProcessingContext.isMemberAccessibleFromBuilderPackagebefore matching — the same accessibility rule already used for member collection elsewhere, so it behaves consistently forB(),ctor(T),build()and later#309factory methods.hasEmptyConstructoris also consumed byJavaLangMapper, which emitsnew X()into generated code — the same rule applies there.Cache fix
BuilderScopeResolvernow tracksbuilderPackagealongside the cached configuration. Resolution results are cached per referenced type; with accessibility in the contract, the accessible-member set depends on the generated builder's package, which can differ between targets sharing a configuration.Tests
resolverUsageScope_RejectsBuilderWithPrivateConstructor— privateB()no longer satisfies the contract.resolverUsageScope_PackagePrivateMembers_AccessibleOnlyFromSamePackage— package-private members qualify when the generated builder shares the package, and are rejected otherwise.475 processor tests green.
Docs
Javadoc on
resolve()/resolveByBuilderContractand both contract descriptions indocs/CONFIGURATION.mdnow state that members must be accessible from the generated builder's package.