mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: support @STRUCT in static methods
This commit is contained in:
parent
b29a084257
commit
d4bedebace
@ -3203,7 +3203,7 @@ fn (mut c Checker) at_expr(mut node ast.AtExpr) ast.Type {
|
||||
node.val = c.table.cur_fn.mod
|
||||
}
|
||||
.struct_name {
|
||||
if c.table.cur_fn.is_method {
|
||||
if c.table.cur_fn.is_method || c.table.cur_fn.is_static_type_method {
|
||||
node.val = c.table.type_to_str(c.table.cur_fn.receiver.typ).all_after_last('.')
|
||||
} else {
|
||||
node.val = ''
|
||||
|
@ -19,6 +19,11 @@ fn (mut t TestStruct) test_struct_w_high_order(cb fn (int) string) string {
|
||||
return 'test' + cb(2)
|
||||
}
|
||||
|
||||
fn TestStruct.static_method() string {
|
||||
assert @STRUCT == 'TestStruct'
|
||||
return @STRUCT
|
||||
}
|
||||
|
||||
struct Abc {
|
||||
}
|
||||
|
||||
@ -112,6 +117,8 @@ fn test_at_struct() {
|
||||
})
|
||||
assert r1 == 'test'
|
||||
assert r2 == 'test2'
|
||||
assert TestStruct.static_method() == 'TestStruct'
|
||||
assert @STRUCT == ''
|
||||
}
|
||||
|
||||
fn test_vmod_file() {
|
||||
|
Loading…
Reference in New Issue
Block a user