Skip to content

Resolve canonical owner of static imports to the most general accessible supertype. - #6203

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_994361319
Oct 13, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_994361319

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Resolve canonical owner of static imports to the most general accessible supertype.

StaticImports.tryCreate previously resolved the canonical owner of an imported static member directly to member.owner without verifying whether that declaring type is accessible from the package of the importing compilation unit. When a public type inherits constants from a package-private supertype or super-interface (such as protobuf large_enum = true shard interfaces), NonCanonicalStaticMemberImport suggested importing from the inaccessible package-private type outside its package.

Walk types.closure(baseType.type) in canonicalOwner to select the most general supertype that is a subtype of member.owner and whose type (and any enclosing types) is accessible from the importing package, and only treat a single imported ClassSymbol as a canonical type import when it is similarly accessible from the importing package.

…ble supertype.

`StaticImports.tryCreate` previously resolved the canonical owner of an imported static member directly to `member.owner` without verifying whether that declaring type is accessible from the package of the importing compilation unit. When a public type inherits constants from a package-private supertype or super-interface (such as protobuf `large_enum = true` shard interfaces), `NonCanonicalStaticMemberImport` suggested importing from the inaccessible package-private type outside its package.

Walk `types.closure(baseType.type)` in `canonicalOwner` to select the most general supertype that is a subtype of `member.owner` and whose type (and any enclosing types) is accessible from the importing package, and only treat a single imported `ClassSymbol` as a canonical type import when it is similarly accessible from the importing package.

PiperOrigin-RevId: 998810316
@copybara-service
copybara-service Bot merged commit 08e222c into master Oct 13, 2026
8 checks passed
@copybara-service
copybara-service Bot deleted the test_994361319 branch October 13, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant