-
Notifications
You must be signed in to change notification settings - Fork 274
[TG-7815] Fix bug in get_recursively_instantiated_type #4913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
NathanJPhillips
wants to merge
5
commits into
diffblue:develop
from
NathanJPhillips:bugfix/get_recursively_instantiated_type
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4abbd7a
Added ability to output generic_parameter_specialization_mapt
NathanJPhillips cf6d6fb
Fixed implementation of get_recursively_instantiated_type
NathanJPhillips e4b7363
Use type_try_dynamic_cast
NathanJPhillips 8125a9f
Remove simplistic method that assumes no recursion
NathanJPhillips ec69b1b
Avoid repeating check that will be done in called function
NathanJPhillips File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,11 +43,10 @@ pointer_typet select_pointer_typet::specialize_generics( | |
&generic_parameter_specialization_map, | ||
generic_parameter_recursion_trackingt &visited_nodes) const | ||
{ | ||
if(is_java_generic_parameter(pointer_type)) | ||
auto parameter = type_try_dynamic_cast<java_generic_parametert>(pointer_type); | ||
if(parameter != nullptr) | ||
{ | ||
const java_generic_parametert ¶meter = | ||
to_java_generic_parameter(pointer_type); | ||
const irep_idt ¶meter_name = parameter.get_name(); | ||
const irep_idt ¶meter_name = parameter->get_name(); | ||
|
||
// avoid infinite recursion by looking at each generic argument from | ||
// previous assignments | ||
|
@@ -82,26 +81,27 @@ pointer_typet select_pointer_typet::specialize_generics( | |
visited_nodes.erase(parameter_name); | ||
return returned_type; | ||
} | ||
else if(pointer_type.subtype().id() == ID_struct_tag) | ||
|
||
auto subtype = | ||
type_try_dynamic_cast<struct_tag_typet>(pointer_type.subtype()); | ||
if(subtype != nullptr && is_java_array_tag(subtype->get_identifier())) | ||
{ | ||
// if the pointer is an array, recursively specialize its element type | ||
const auto &array_subtype = to_struct_tag_type(pointer_type.subtype()); | ||
if(is_java_array_tag(array_subtype.get_identifier())) | ||
{ | ||
const typet &array_element_type = java_array_element_type(array_subtype); | ||
if(array_element_type.id() == ID_pointer) | ||
{ | ||
const pointer_typet &new_array_type = specialize_generics( | ||
to_pointer_type(array_element_type), | ||
generic_parameter_specialization_map, | ||
visited_nodes); | ||
|
||
pointer_typet replacement_array_type = java_array_type('a'); | ||
replacement_array_type.subtype().set(ID_element_type, new_array_type); | ||
return replacement_array_type; | ||
} | ||
} | ||
auto array_element_type = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
type_try_dynamic_cast<pointer_typet>(java_array_element_type(*subtype)); | ||
if(array_element_type == nullptr) | ||
return pointer_type; | ||
|
||
const pointer_typet &new_array_type = specialize_generics( | ||
*array_element_type, | ||
generic_parameter_specialization_map, | ||
visited_nodes); | ||
|
||
pointer_typet replacement_array_type = java_array_type('a'); | ||
replacement_array_type.subtype().set(ID_element_type, new_array_type); | ||
return replacement_array_type; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't re-space in the same commit as a substantial change |
||
return pointer_type; | ||
} | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be in a separate commit. It does not correspond to the commit description. There are several things being changed here, and it makes it difficult to check that this commit does not introduce a behavioural change.