diff --git a/vlib/v/ast/types.v b/vlib/v/ast/types.v index 4bd3448cdf..31dd3896aa 100644 --- a/vlib/v/ast/types.v +++ b/vlib/v/ast/types.v @@ -208,6 +208,7 @@ pub mut: conversions shared map[int][]Type // generic interface support is_generic bool + is_markused bool generic_types []Type concrete_types []Type parent_type Type diff --git a/vlib/v/markused/walker.v b/vlib/v/markused/walker.v index 39ae73cee2..08e13545dd 100644 --- a/vlib/v/markused/walker.v +++ b/vlib/v/markused/walker.v @@ -169,6 +169,8 @@ pub fn (mut w Walker) mark_markused_syms() { for sym in w.table.type_symbols { if sym.info is ast.Struct && sym.info.is_markused { w.mark_by_sym(sym) + } else if sym.info is ast.Interface && sym.info.is_markused { + w.mark_by_sym(sym) } } } diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index 78db510f40..dab6d23b86 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -640,6 +640,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl { info: ast.Interface{ types: [] is_generic: generic_types.len > 0 + is_markused: attrs.contains('markused') generic_types: generic_types } language: language diff --git a/vlib/v/tests/skip_unused/interface_struct_unused.run.out b/vlib/v/tests/skip_unused/interface_struct_unused.run.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vlib/v/tests/skip_unused/interface_struct_unused.skip_unused.run.out b/vlib/v/tests/skip_unused/interface_struct_unused.skip_unused.run.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vlib/v/tests/skip_unused/interface_struct_unused.vv b/vlib/v/tests/skip_unused/interface_struct_unused.vv new file mode 100644 index 0000000000..7197e22d97 --- /dev/null +++ b/vlib/v/tests/skip_unused/interface_struct_unused.vv @@ -0,0 +1,7 @@ +@[markused] +struct Foo {} + +@[markused] +interface Bar { + a Foo +}