ir: fix interface call edge case
A function on a type that is put in an interface must not be assumed to not need a context pointer when it isn't directly put in a function pointer, because the interface call side won't know this and pass an extra parameter with that extra function pointer. This is usually not a problem but WebAssembly has strict checks on function signatures so this resulted in an error when running src/examples/test/test.go.
Этот коммит содержится в:
родитель
97caabb8c2
коммит
dda9c1cc6e
1 изменённых файлов: 6 добавлений и 0 удалений
|
@ -416,6 +416,12 @@ func (p *Program) AllInterfaces() []*Interface {
|
||||||
|
|
||||||
func (p *Program) FunctionNeedsContext(f *Function) bool {
|
func (p *Program) FunctionNeedsContext(f *Function) bool {
|
||||||
if !f.addressTaken {
|
if !f.addressTaken {
|
||||||
|
if f.Signature.Recv() != nil {
|
||||||
|
_, hasInterfaceConversion := p.TypeNum(f.Signature.Recv().Type())
|
||||||
|
if hasInterfaceConversion && p.SignatureNeedsContext(f.Signature) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return p.SignatureNeedsContext(f.Signature)
|
return p.SignatureNeedsContext(f.Signature)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче