Report error when trying to create instance of static class, patch by
authorJuerg Billeter <j@bitron.ch>
Thu, 8 May 2008 19:09:25 +0000 (19:09 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Thu, 8 May 2008 19:09:25 +0000 (19:09 +0000)
2008-05-08  Juerg Billeter  <j@bitron.ch>

* vala/valasemanticanalyzer.vala:

Report error when trying to create instance of static class,
patch by Andreas Brauchli, fixes bug 516779

svn path=/trunk/; revision=1342

ChangeLog
vala/valasemanticanalyzer.vala

index cdccbaa..5a47236 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,13 @@
 2008-05-08  Jürg Billeter  <j@bitron.ch>
 
        * vala/valasemanticanalyzer.vala:
+
+       Report error when trying to create instance of static class,
+       patch by Andreas Brauchli, fixes bug 516779
+
+2008-05-08  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valasemanticanalyzer.vala:
        * vala/valastruct.vala:
 
        Check number of type arguments in object creation expression,
index e594fda..6264f96 100644 (file)
@@ -2334,6 +2334,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                                return;
                        }
 
+                       if (cl.is_static) {
+                               expr.static_type = null;
+                               expr.error = true;
+                               Report.error (expr.source_reference, "Can't create instance of static class `%s'".printf (cl.get_full_name ()));
+                               return;
+                       }
+
                        if (expr.symbol_reference == null) {
                                expr.symbol_reference = cl.default_construction_method;
                        }