vfmt: keep selective imported names used for generic calls

master
Delyan Angelov 2022-05-19 12:48:37 +03:00
parent 15c62bc8e8
commit 634e8c3624
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 5 additions and 0 deletions

View File

@ -1694,6 +1694,7 @@ fn (mut f Fmt) write_generic_call_if_require(node ast.CallExpr) {
name = 'JS.' + name
}
f.write(name)
f.mark_import_as_used(name)
if i != node.concrete_types.len - 1 {
f.write(', ')
}

View File

@ -1,12 +1,16 @@
import math.complex { Complex }
import gg { MouseButton }
import time { Duration }
import modtest { Test }
fn keep_imported_enum_map_key() {
bm := map[MouseButton]string{}
}
fn generic<T>() {}
fn main() {
_ := Duration(10) // keep cast type
assert *(&f64(&byte(&num) + __offsetof(Complex, re))) == 1.0
generic<Test>()
}