@@ -24,6 +24,7 @@ public class ObjectiveCKmpMethodTranslatorTest extends GenerationTest {
2424 @ Override
2525 public void setUp () throws IOException {
2626 super .setUp ();
27+ options .load (new String [] {"--objc-generics" });
2728 addSourceFile (
2829 """
2930 package com.google.common.collect;
@@ -276,7 +277,8 @@ public List<List<String>> getMatrix() {
276277 assertInTranslation (
277278 testImplementation ,
278279 "return (NSArray<NSArray<NSString *> *> *) [Adapter"
279- + " fromJavaUtilList_JavaUtilList_WithJavaUtilList:(id<JavaUtilList>) [self getMatrix]]" );
280+ + " fromJavaUtilList_JavaUtilList_WithJavaUtilList:(id<JavaUtilList>) [self"
281+ + " getMatrix]]" );
280282 }
281283
282284 /** Tests mixed nested collection conversion with @ObjectiveCKmpMethod. */
@@ -1061,7 +1063,6 @@ public ImmutableList<CustomClass> getItems() {
10611063 assertNotInTranslation (
10621064 concreteHeader , "- (void)setItems:(NSArray<MyPkgCustomClass *> *)items;" );
10631065 assertNotInTranslation (concreteHeader , "- (NSArray<MyPkgCustomClass *> *)getItems;" );
1064- assertNotInTranslation (concreteHeader , "@class MyPkgCustomClass;" );
10651066
10661067 String concreteImpl = translateSourceFile ("ConcreteClass" , "ConcreteClass.m" );
10671068 assertNotInTranslation (concreteImpl , "- (void)setItems:(NSArray<MyPkgCustomClass *> *)items {" );
@@ -1405,6 +1406,37 @@ void ConstTest_initWithList_(ConstTest *self_, NSArray<NSString *> *list) {
14051406 """ );
14061407 }
14071408
1409+ public void testObjCGenerics () throws IOException {
1410+
1411+ addSourceFile (
1412+ """
1413+ import com.google.j2objc.annotations.ObjectiveCKmpMethod;
1414+ import java.util.List;
1415+ public class GenericsOn {
1416+ @ObjectiveCKmpMethod(selector="setList:", adapter=Adapter.class)
1417+ public void setList(List<String> list) {}
1418+ }
1419+ """ ,
1420+ "GenericsOn.java" );
1421+ String headerOn = translateSourceFile ("GenericsOn" , "GenericsOn.h" );
1422+ assertInTranslation (headerOn , "- (void)setList:(NSArray<NSString *> *)list;" );
1423+
1424+ options .setAsObjCGenericDecl (false );
1425+ addSourceFile (
1426+ """
1427+ import com.google.j2objc.annotations.ObjectiveCKmpMethod;
1428+ import java.util.List;
1429+ public class GenericsOff {
1430+ @ObjectiveCKmpMethod(selector="setList:", adapter=Adapter.class)
1431+ public void setList(List<String> list) {}
1432+ }
1433+ """ ,
1434+ "GenericsOff.java" );
1435+ String headerOff = translateSourceFile ("GenericsOff" , "GenericsOff.h" );
1436+ assertInTranslation (headerOff , "- (void)setList:(NSArray *)list;" );
1437+ options .setAsObjCGenericDecl (true );
1438+ }
1439+
14081440 public void testSetOfBooleanFails () throws IOException {
14091441 addSourceFile (
14101442 """
0 commit comments