[vala/0.34] vala: Report error for missing type-parameter on enclosing type



commit 31d1b953401f99992307a962a702cf62c9b70f2a
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Nov 19 16:27:22 2017 +0100

    vala: Report error for missing type-parameter on enclosing type
    
    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              |    1 +
 tests/objects/bug587905.test   |   10 ++++++++++
 vala/valasemanticanalyzer.vala |    6 +++++-
 3 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f853481..a631cef 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -156,6 +156,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
index 0000000..87bf76c
--- /dev/null
+++ b/tests/objects/bug587905.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Generic<T> {
+       class Nested {
+               public T member;
+       }
+}
+
+void main () {
+}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index 563ce0e..7cabd64 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -817,7 +817,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) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]