Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* not found, it will fallback to a method that matches {@code List<?>}.
*/
@Documented
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.RECORD_COMPONENT})
@Retention(RetentionPolicy.CLASS)
public @interface ObjectiveCKmpMethod {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2143,5 +2143,29 @@ public void verifyList(List<List<List<Foo>>> list) {}
}
""");
}

public void testRecordComponentAnnotation() throws IOException {
addSourceFile(
"""
import com.google.j2objc.annotations.ObjectiveCKmpMethod;
import java.util.List;

public record TestRecord(
@ObjectiveCKmpMethod(selector = "itemsAsList", adapter = Adapter.class)
List<String> items) {}
""",
"TestRecord.java");
String header = translateSourceFile("TestRecord", "TestRecord.h");
assertInTranslation(header, "- (NSArray<NSString *> *)itemsAsList;");

String impl = translateSourceFile("TestRecord", "TestRecord.m");
assertInTranslation(
impl,
"""
- (NSArray<NSString *> *)itemsAsList {
return (NSArray<NSString *> *) [Adapter fromJavaUtilListWithJavaUtilList:[self items]];
}
""");
}
}

Loading