From 9eee1314236284b53c7fd7821cc4d5ca3cae1a89 Mon Sep 17 00:00:00 2001 From: Mark aka walkingdevel <104449470+walkingdevel@users.noreply.github.com> Date: Fri, 28 Apr 2023 19:18:23 +0000 Subject: [PATCH] checker: make type_implements() return false if methods of interface didn't implement (#18076) --- vlib/v/checker/checker.v | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 475b123403..c2ce720b05 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -914,6 +914,8 @@ fn (mut c Checker) type_implements(typ ast.Type, interface_type ast.Type, pos to } // voidptr is an escape hatch, it should be allowed to be passed if utyp != ast.voidptr_type && utyp != ast.nil_type { + mut are_methods_implemented := true + // Verify methods for imethod in imethods { method := c.table.find_method_with_embeds(typ_sym, imethod.name) or { @@ -930,6 +932,7 @@ fn (mut c Checker) type_implements(typ ast.Type, interface_type ast.Type, pos to typ_sym.find_method_with_generic_parent(imethod.name) or { c.error("`${styp}` doesn't implement method `${imethod.name}` of interface `${inter_sym.name}`", pos) + are_methods_implemented = false continue } } @@ -944,6 +947,10 @@ fn (mut c Checker) type_implements(typ ast.Type, interface_type ast.Type, pos to return false } } + + if !are_methods_implemented { + return false + } } // Verify fields if mut inter_sym.info is ast.Interface {