Revert "cgen: fix generics with generics fn type parameter (#10078)"
This reverts commit e310513a5f
.
pull/10081/head
parent
0bc80951e3
commit
d3de91ee86
|
@ -2373,7 +2373,7 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
|
||||||
}
|
}
|
||||||
else {}
|
else {}
|
||||||
}
|
}
|
||||||
right_sym := g.table.get_type_symbol(g.unwrap_generic(val_type))
|
right_sym := g.table.get_type_symbol(val_type)
|
||||||
is_fixed_array_copy := right_sym.kind == .array_fixed && val is ast.Ident
|
is_fixed_array_copy := right_sym.kind == .array_fixed && val is ast.Ident
|
||||||
g.is_assign_lhs = true
|
g.is_assign_lhs = true
|
||||||
g.assign_op = assign_stmt.op
|
g.assign_op = assign_stmt.op
|
||||||
|
|
|
@ -4,40 +4,19 @@ fn neg(a int) int {
|
||||||
|
|
||||||
fn indirect_call(func fn (int) int, a int) int {
|
fn indirect_call(func fn (int) int, a int) int {
|
||||||
println(typeof(func).name)
|
println(typeof(func).name)
|
||||||
assert typeof(func).name == typeof(neg).name
|
|
||||||
return func(a)
|
return func(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generic_call<T>(func T, a int) int {
|
fn generic_call<T>(func T, a int) int {
|
||||||
println(T.name)
|
println(T.name)
|
||||||
assert T.name == typeof(neg).name
|
|
||||||
return func(a)
|
return func(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generic_indirect_call<T>(func T, a int) int {
|
fn generic_indirect_call<T>(func T, a int) int {
|
||||||
println(T.name)
|
println(T.name)
|
||||||
assert T.name == typeof(neg).name
|
|
||||||
return indirect_call(func, a)
|
return indirect_call(func, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn indirect_call_v2(func fn (int) int, a int) int {
|
|
||||||
f := func
|
|
||||||
assert typeof(f).name == typeof(neg).name
|
|
||||||
return f(a)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generic_call_v2<T>(func T, a int) int {
|
|
||||||
f := func
|
|
||||||
assert typeof(f).name == typeof(neg).name
|
|
||||||
return f(a)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generic_indirect_call_v2<T>(func T, a int) int {
|
|
||||||
f := func
|
|
||||||
assert typeof(f).name == typeof(neg).name
|
|
||||||
return indirect_call_v2(f, a)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_generics_with_generics_fn_type_parameter() {
|
fn test_generics_with_generics_fn_type_parameter() {
|
||||||
mut ret := 0
|
mut ret := 0
|
||||||
|
|
||||||
|
@ -52,16 +31,4 @@ fn test_generics_with_generics_fn_type_parameter() {
|
||||||
ret = generic_indirect_call(neg, 4)
|
ret = generic_indirect_call(neg, 4)
|
||||||
println(ret)
|
println(ret)
|
||||||
assert ret == -4
|
assert ret == -4
|
||||||
|
|
||||||
ret = indirect_call_v2(neg, 5)
|
|
||||||
println(ret)
|
|
||||||
assert ret == -5
|
|
||||||
|
|
||||||
ret = generic_call_v2(neg, 6)
|
|
||||||
println(ret)
|
|
||||||
assert ret == -6
|
|
||||||
|
|
||||||
ret = generic_indirect_call_v2(neg, 7)
|
|
||||||
println(ret)
|
|
||||||
assert ret == -7
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue