[vala/staging: 14/14] Make sure type check expression has valid type
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 14/14] Make sure type check expression has valid type
- Date: Sun, 24 Aug 2014 11:57:36 +0000 (UTC)
commit 57c7d28957ebbc4727584d5e7f102bfa1b71bc65
Author: Simon Werbeck <simon werbeck gmail com>
Date: Wed Aug 13 02:51:11 2014 +0200
Make sure type check expression has valid type
Fixes bug 696729
codegen/valaccodebasemodule.vala | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index dae3334..ca282a1 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5456,7 +5456,19 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public override void visit_type_check (TypeCheck expr) {
generate_type_declaration (expr.type_reference, cfile);
- set_cvalue (expr, create_type_check (get_cvalue (expr.expression), expr.type_reference));
+ var type = expr.expression.value_type;
+ var pointer_type = type as PointerType;
+ if (pointer_type != null) {
+ type = pointer_type.base_type;
+ }
+ var cl = type.data_type as Class;
+ var iface = type.data_type as Interface;
+ if ((cl != null && !cl.is_compact) || iface != null || type is GenericType || type is
ErrorType) {
+ set_cvalue (expr, create_type_check (get_cvalue (expr.expression),
expr.type_reference));
+ } else {
+ set_cvalue (expr, new CCodeInvalidExpression ());
+ }
+
if (get_cvalue (expr) is CCodeInvalidExpression) {
Report.error (expr.source_reference, "type check expressions not supported for
compact classes, structs, and enums");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]