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.
Этот коммит содержится в:
Ayke van Laethem 2018-10-21 01:33:40 +02:00
родитель 97caabb8c2
коммит dda9c1cc6e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -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)