markused: fix `-skip-unused` on programs with generic methods (fix #12306)
parent
462d097bf5
commit
159a9c3070
|
@ -203,6 +203,12 @@ pub fn mark_used(mut table ast.Table, pref &pref.Preferences, ast_files []&ast.F
|
|||
all_fn_root_names << k
|
||||
continue
|
||||
}
|
||||
if mfn.receiver.typ != ast.void_type && mfn.receiver.typ.has_flag(.generic) {
|
||||
// generic methods may be used in cgen after specialisation :-|
|
||||
// TODO: move generic method specialisation from cgen to before markused
|
||||
all_fn_root_names << k
|
||||
continue
|
||||
}
|
||||
// testing framework:
|
||||
if pref.is_test {
|
||||
if k.starts_with('test_') || k.contains('.test_') {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0
|
|
@ -0,0 +1 @@
|
|||
0
|
|
@ -0,0 +1,31 @@
|
|||
interface Something {
|
||||
i int
|
||||
}
|
||||
|
||||
struct Some {
|
||||
i int
|
||||
}
|
||||
|
||||
struct App<M> {
|
||||
f M
|
||||
}
|
||||
|
||||
fn (mut self App<M>) next<M, T>(input T) f64 {
|
||||
$if M is Something {
|
||||
return 0
|
||||
} $else {
|
||||
panic('${typeof(M.typ).name} is not supported')
|
||||
return 1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fn main() {
|
||||
mut app := App<Some>{
|
||||
f: Some{
|
||||
i: 10
|
||||
}
|
||||
}
|
||||
assert app.next(1) == 0
|
||||
println(app.next(1))
|
||||
}
|
Loading…
Reference in New Issue