Skip to content

Commit f4636ee

Browse files
Add can_cast_type and precondition.
Also removes an irrelevant unit test due to this change.
1 parent 43c57bd commit f4636ee

File tree

3 files changed

+8
-39
lines changed

3 files changed

+8
-39
lines changed

jbmc/src/java_bytecode/java_types.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,21 @@ class java_method_typet : public code_typet
284284
}
285285
};
286286

287+
template<>
288+
inline bool can_cast_type<java_method_typet>(const typet &type)
289+
{
290+
return type.id() == ID_code && type.get_bool(ID_C_java_method_type);
291+
}
292+
287293
inline const java_method_typet &to_java_method_type(const typet &type)
288294
{
289-
PRECONDITION(type.id() == ID_code);
295+
PRECONDITION(can_cast_type<java_method_typet>(type));
290296
return static_cast<const java_method_typet &>(type);
291297
}
292298

293299
inline java_method_typet &to_java_method_type(typet &type)
294300
{
295-
PRECONDITION(type.id() == ID_code);
296-
type.set(ID_C_java_method_type, true);
301+
PRECONDITION(can_cast_type<java_method_typet>(type));
297302
return static_cast<java_method_typet &>(type);
298303
}
299304

jbmc/unit/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ SRC += java_bytecode/goto-programs/class_hierarchy_output.cpp \
2121
java_bytecode/java_types/erase_type_arguments.cpp \
2222
java_bytecode/java_types/generic_type_index.cpp \
2323
java_bytecode/java_types/java_generic_symbol_type.cpp \
24-
java_bytecode/java_types/java_method_type.cpp \
2524
java_bytecode/java_types/java_type_from_string.cpp \
2625
java_bytecode/java_utils_test.cpp \
2726
java_bytecode/load_method_by_regex.cpp \

jbmc/unit/java_bytecode/java_types/java_method_type.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)