[vala/staging: 14/14] Make sure type check expression has valid type



commit 13c72758fe80da9911df078ab032632ba66b8886
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 |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index dae3334..25ebcb0 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5456,7 +5456,15 @@ 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 sym = expr.expression.value_type.data_type;
+               var cl = sym as Class;
+               var iface = sym as Interface;
+               if ((cl != null && !cl.is_compact) || iface != null || expr.expression.value_type is 
GenericType || expr.expression.value_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]