]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Report error for missing type-parameter on enclosing type
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 19 Nov 2017 15:27:22 +0000 (16:27 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 29 Nov 2017 16:05:40 +0000 (17:05 +0100)
Make a qualified guess for the cause of the problem instead of triggering
an assertion.

https://bugzilla.gnome.org/show_bug.cgi?id=587905

tests/Makefile.am
tests/objects/bug587905.test [new file with mode: 0644]
vala/valasemanticanalyzer.vala

index 729cbc6aeee5b7703a0c8e97a417c021fc6714fb..c82aca1399f8de2b3dfe186f67442f5896b25286 100644 (file)
@@ -185,6 +185,7 @@ TESTS = \
        objects/test-029.vala \
        objects/test-034.vala \
        objects/bug566909.vala \
+       objects/bug587905.test \
        objects/bug588203.vala \
        objects/bug589928.vala \
        objects/bug593260.vala \
diff --git a/tests/objects/bug587905.test b/tests/objects/bug587905.test
new file mode 100644 (file)
index 0000000..87bf76c
--- /dev/null
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Generic<T> {
+       class Nested {
+               public T member;
+       }
+}
+
+void main () {
+}
index 32a8d2d28f7b89df73f1f22bdfe0bcddd1064be0..a0a7e3d0a21ab50730756537e1df24ca171b23e3 100644 (file)
@@ -822,7 +822,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                                // trace type arguments back to the datatype where the method has been declared
                                var instance_type = get_instance_base_type_for_member (derived_instance_type, (TypeSymbol) generic_type.type_parameter.parent_symbol, node_reference);
 
-                               assert (instance_type != null);
+                               if (instance_type == null) {
+                                       Report.error (node_reference.source_reference, "The type-parameter `%s' must be defined on enclosing type".printf (generic_type.to_string ()));
+                                       node_reference.error = true;
+                                       return null;
+                               }
 
                                int param_index;
                                if (instance_type is DelegateType) {