Repository navigation
Preserve Objective-C lightweight generics on instance @Property fields and record components. - #2910
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
force-pushed
the
test_1013969826
branch
from
November 6, 2026 19:40
8ed58be to
01f9b82
Compare
…lds and record components. Previously, `PropertyGenerator` only preserved Objective-C generics on method-based `@Property` declarations and static companion properties (`staticToInstance`), while erasing generics on instance `@Property` fields (including all Java `record` component properties synthesized by `RecordExpander`). As a result, a Java record component such as `Foo<Void> foo` generated an erased `@property (readonly, nonatomic) Foo *foo;` alongside the generic accessor method `- (Foo<JavaLangVoid *> *)foo;`, causing Swift to import the property as `Foo<AnyObject>` instead of `Foo<JavaLangVoid>`. In addition, `NameTable.isTranslatableTypeVariable` checked `enclosingElement.getKind() != ElementKind.CLASS` rather than `!enclosingElement.getKind().isClass()`, which caused type parameters on generic `record` declarations (`ElementKind.RECORD`) to be erased to `id` in member declarations even though `@interface RecordName<T>` declared `<T>`. Update `PropertyGenerator`, `HeaderImportCollector`, and `NameTable` so non-static `@Property` fields and generic `record` components preserve Objective-C lightweight generics and forward-declare their generic type arguments when Objective-C generics are enabled. PiperOrigin-RevId: 1013969826
copybara-service
Bot
force-pushed
the
test_1013969826
branch
from
November 7, 2026 02:50
01f9b82 to
d233589
Compare
This branch has not been deployed
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.
Preserve Objective-C lightweight generics on instance
@Propertyfields and record components.Previously,
PropertyGeneratoronly preserved Objective-C generics on method-based@Propertydeclarations and static companion properties (staticToInstance), while erasing generics on instance@Propertyfields (including all Javarecordcomponent properties synthesized byRecordExpander). As a result, a Java record component such asFoo<Void> foogenerated an erased@property (readonly, nonatomic) Foo *foo;alongside the generic accessor method- (Foo<JavaLangVoid *> *)foo;, causing Swift to import the property asFoo<AnyObject>instead ofFoo<JavaLangVoid>.In addition,
NameTable.isTranslatableTypeVariablecheckedenclosingElement.getKind() != ElementKind.CLASSrather than!enclosingElement.getKind().isClass(), which caused type parameters on genericrecorddeclarations (ElementKind.RECORD) to be erased toidin member declarations even though@interface RecordName<T>declared<T>.Update
PropertyGenerator,HeaderImportCollector, andNameTableso non-static@Propertyfields and genericrecordcomponents preserve Objective-C lightweight generics and forward-declare their generic type arguments when Objective-C generics are enabled.