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



commit 1c7a46c7dce4c9db638876ffa1fa51248d70060a
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 729cbc6..c82aca1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
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 32a8d2d..a0a7e3d 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -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) {


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