|
36 | 36 |
|
37 | 37 | #include <goto-programs/cfg.h>
|
38 | 38 | #include <goto-programs/class_hierarchy.h>
|
| 39 | +#include <goto-programs/remove_returns.h> |
39 | 40 | #include <goto-programs/resolve_inherited_component.h>
|
40 | 41 |
|
41 | 42 | #include <analyses/cfg_dominators.h>
|
42 | 43 | #include <analyses/uncaught_exceptions_analysis.h>
|
43 | 44 |
|
44 |
| -#include <limits> |
45 | 45 | #include <algorithm>
|
46 | 46 | #include <functional>
|
47 |
| -#include <unordered_set> |
| 47 | +#include <limits> |
48 | 48 | #include <regex>
|
| 49 | +#include <unordered_set> |
49 | 50 |
|
50 | 51 | /// Given a string of the format '?blah?', will return true when compared
|
51 | 52 | /// against a string that matches appart from any characters that are '?'
|
@@ -2105,7 +2106,18 @@ void java_bytecode_convert_methodt::convert_invoke(
|
2105 | 2106 | // whereas the type given by the invoke instruction doesn't and is therefore
|
2106 | 2107 | // less accurate.
|
2107 | 2108 | if(method_symbol != symbol_table.symbols.end())
|
2108 |
| - arg0.type() = to_java_method_type(method_symbol->second.type); |
| 2109 | + { |
| 2110 | + const auto &restored_type = |
| 2111 | + original_return_type(symbol_table, invoked_method_id); |
| 2112 | + // Note the number of parameters might change here due to constructors using |
| 2113 | + // invokespecial will have zero arguments (the `this` is added below) |
| 2114 | + // but the symbol for the <init> will have the this parameter. |
| 2115 | + INVARIANT( |
| 2116 | + to_java_method_type(arg0.type()).return_type().id() == |
| 2117 | + restored_type.return_type().id(), |
| 2118 | + "Function return type must not change in kind"); |
| 2119 | + arg0.type() = restored_type; |
| 2120 | + } |
2109 | 2121 |
|
2110 | 2122 | // Note arg0 and arg0.type() are subject to many side-effects in this method,
|
2111 | 2123 | // then finally used to populate the call instruction.
|
|
0 commit comments