Skip to content

Commit 706179f

Browse files
authored
checker: fix generic resolve for external module generic static method call (fix #21476) (#25634)
1 parent 260d29b commit 706179f

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

vlib/v/checker/fn.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,9 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
11571157
func = f
11581158
node.name = qualified_name
11591159
unsafe { c.table.fns[qualified_name].usages++ }
1160+
if !c.table.register_fn_concrete_types(f.name, concrete_types) {
1161+
c.need_recheck_generic_fns = true
1162+
}
11601163
break
11611164
}
11621165
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module zmod_foo
2+
3+
pub struct Foo[T] {}
4+
5+
pub fn Foo.new[T](embed T) &Foo[T] {
6+
return &Foo[T]{}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module main
2+
3+
import zmod_foo { Foo }
4+
5+
struct Bar {}
6+
7+
fn main() {
8+
// note: will succeed with foo.Foo
9+
f := Foo.new[Bar](Bar{})
10+
11+
println(typeof(f).name)
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module main
2+
3+
fn test_compiles() {
4+
assert true
5+
}

vlib/v/tests/project_issue_21476/v.mod

Whitespace-only changes.

0 commit comments

Comments
 (0)