GNOME Bugzilla – Bug 587905
Generic type parameter inside non-generic nested class triggers assertion instead of proper error
Last modified: 2018-02-17 15:40:04 UTC
Example: class Generic<T> { class Nested { public T member; } } Results in: ERROR:valasemanticanalyzer.c:2934:vala_semantic_analyzer_get_actual_type: assertion failed: (instance_type != NULL)
Confirmed, although this code is invalid. Inner classes in generics are considered static. Vala needs to emit an error though instead of creating invalid code. post-0.7.7 Vala emits: /tmp/foo.vala.c:238: error: dereferencing pointer to incomplete type if the offending member is public, and /tmp/foo.vala.c: In function 'generic_nested_finalize': /tmp/foo.vala.c:244: error: 'GenericNestedPrivate' has no member named 't_destroy_func' if it is private.
*** Bug 635983 has been marked as a duplicate of this bug. ***
i don't know wheter this is too obvious, but a workaround is passing the template down to the inner class like this: class Generic<T> { class Nested<T> { public T member; } }
Created attachment 364008 [details] [review] 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.
Attachment 364008 [details] pushed as 6b656b0 - vala: Report error for missing type-parameter on enclosing type
*** Bug 737500 has been marked as a duplicate of this bug. ***