@@ -326,5 +326,72 @@ SCENARIO(
326326 }
327327 }
328328 }
329+ WHEN (
330+ " We specialise the class with an array we should have appropriate types" )
331+ {
332+ specialise_generic_from_component (
333+ harness_class, " genericArrayArrayField" , new_symbol_table);
334+ THEN (
335+ " There should be a specialised version of the class in the symbol "
336+ " table" )
337+ {
338+ const std::string specialised_string =
339+ " <java::array[reference]of_"
340+ " java::java.lang.Float>" ;
341+ const irep_idt specialised_class_name = id2string (harness_class) + " $" +
342+ id2string (inner_class) +
343+ specialised_string;
344+
345+ REQUIRE (new_symbol_table.has_symbol (specialised_class_name));
346+
347+ const symbolt test_class_symbol =
348+ new_symbol_table.lookup_ref (specialised_class_name);
349+
350+ REQUIRE (test_class_symbol.type .id () == ID_struct);
351+ THEN (" The array field should be specialised to be an array of floats" )
352+ {
353+ const struct_typet::componentt &field_component =
354+ require_type::require_component (
355+ to_struct_type (test_class_symbol.type ), " arrayField" );
356+
357+ const pointer_typet &component_pointer_type =
358+ require_type::require_pointer (field_component.type (), {});
359+
360+ const symbol_typet &pointer_subtype = require_type::require_symbol (
361+ component_pointer_type.subtype (), " java::array[reference]" );
362+
363+ const typet &array_type = java_array_element_type (pointer_subtype);
364+
365+ require_type::require_pointer (
366+ array_type, symbol_typet (" java::array[reference]" ));
367+
368+ const typet &array_subtype =
369+ java_array_element_type (to_symbol_type (array_type.subtype ()));
370+
371+ require_type::require_pointer (
372+ array_subtype, symbol_typet (" java::java.lang.Float" ));
373+ }
374+
375+ THEN (
376+ " The generic class field should be specialised to be a generic "
377+ " class with the appropriate type" )
378+ {
379+ const struct_typet::componentt &field_component =
380+ require_type::require_component (
381+ to_struct_type (test_class_symbol.type ), " genericClassField" );
382+
383+ const java_generic_typet ¶m_type =
384+ require_type::require_java_generic_type (
385+ field_component.type (),
386+ {{require_type::type_parameter_kindt::Inst,
387+ " java::array[reference]" }});
388+
389+ const typet &array_type = java_array_element_type (
390+ to_symbol_type (param_type.generic_type_variables ()[0 ].subtype ()));
391+ require_type::require_pointer (
392+ array_type, symbol_typet (" java::java.lang.Float" ));
393+ }
394+ }
395+ }
329396 }
330397}
0 commit comments