diff --git a/blueprintcompiler/gir.py b/blueprintcompiler/gir.py index 7c5a67d..32eca16 100644 --- a/blueprintcompiler/gir.py +++ b/blueprintcompiler/gir.py @@ -257,9 +257,11 @@ class Class(GirNode, GirType): return True elif self.parent and self.parent.assignable_to(other): return True - elif other in self.implements: - return True else: + for iface in self.implements: + if self.get_containing(Namespace).lookup_type(iface).assignable_to(other): + return True + return False diff --git a/tests/sample_errors/does_not_implement.blp b/tests/sample_errors/does_not_implement.blp new file mode 100644 index 0000000..31bbf06 --- /dev/null +++ b/tests/sample_errors/does_not_implement.blp @@ -0,0 +1,7 @@ +using Gtk 4.0; + +Label label {} + +DropDown { + model: label; +} diff --git a/tests/sample_errors/does_not_implement.err b/tests/sample_errors/does_not_implement.err new file mode 100644 index 0000000..ad64f1c --- /dev/null +++ b/tests/sample_errors/does_not_implement.err @@ -0,0 +1 @@ +6,10,5,Cannot assign Gtk.Label to Gio.ListModel diff --git a/tests/samples/string_list.blp b/tests/samples/string_list.blp index 2f1198c..91af385 100644 --- a/tests/samples/string_list.blp +++ b/tests/samples/string_list.blp @@ -1,8 +1,12 @@ using Gtk 4.0; -StringList { +StringList greetings { strings [ "Hello, world!", _("Hello!"), ] } + +Gtk.DropDown { + model: greetings; +} diff --git a/tests/samples/string_list.ui b/tests/samples/string_list.ui index 02078a0..156bc09 100644 --- a/tests/samples/string_list.ui +++ b/tests/samples/string_list.ui @@ -1,10 +1,13 @@ - + Hello, world! Hello! + + greetings + diff --git a/tests/test_samples.py b/tests/test_samples.py index 572b706..70553b4 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -144,6 +144,7 @@ class TestSamples(unittest.TestCase): self.assert_sample_error("class_assign") self.assert_sample_error("class_dne") self.assert_sample_error("consecutive_unexpected_tokens") + self.assert_sample_error("does_not_implement") self.assert_sample_error("duplicate_obj_id") self.assert_sample_error("enum_member_dne") self.assert_sample_error("filters_in_non_file_filter")