cgen: fix alias of array that has builtin method (#14432)
parent
d7b1e57186
commit
020845f6c3
|
@ -941,7 +941,7 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
||||||
if left_sym.kind == .map && node.name in ['clone', 'move'] {
|
if left_sym.kind == .map && node.name in ['clone', 'move'] {
|
||||||
receiver_type_name = 'map'
|
receiver_type_name = 'map'
|
||||||
}
|
}
|
||||||
if final_left_sym.kind == .array
|
if final_left_sym.kind == .array && !(left_sym.kind == .alias && left_sym.has_method(node.name))
|
||||||
&& node.name in ['repeat', 'sort_with_compare', 'free', 'push_many', 'trim', 'first', 'last', 'pop', 'clone', 'reverse', 'slice', 'pointers'] {
|
&& node.name in ['repeat', 'sort_with_compare', 'free', 'push_many', 'trim', 'first', 'last', 'pop', 'clone', 'reverse', 'slice', 'pointers'] {
|
||||||
if !(left_sym.info is ast.Alias && typ_sym.has_method(node.name)) {
|
if !(left_sym.info is ast.Alias && typ_sym.has_method(node.name)) {
|
||||||
// `array_Xyz_clone` => `array_clone`
|
// `array_Xyz_clone` => `array_clone`
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
type Alias = []int
|
||||||
|
|
||||||
|
fn (a Alias) last() int {
|
||||||
|
return 22
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_alias_array_has_method() {
|
||||||
|
ret := Alias([0]).last()
|
||||||
|
println(ret)
|
||||||
|
assert ret == 22
|
||||||
|
}
|
Loading…
Reference in New Issue