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