compiler: Fix ChangeInterface
Keep the concrete type as interface type. Don't use the previous interface type as type number.
Этот коммит содержится в:
родитель
9ad59bf001
коммит
6b3e394dce
1 изменённых файлов: 7 добавлений и 6 удалений
13
tgo.go
13
tgo.go
|
@ -1108,12 +1108,13 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) {
|
||||||
// the subroutine is blocking.
|
// the subroutine is blocking.
|
||||||
return c.parseCall(frame, expr.Common(), frame.taskHandle)
|
return c.parseCall(frame, expr.Common(), frame.taskHandle)
|
||||||
case *ssa.ChangeInterface:
|
case *ssa.ChangeInterface:
|
||||||
value, err := c.parseExpr(frame, expr.X)
|
// Do not change between interface types: always use the underlying
|
||||||
if err != nil {
|
// (concrete) type in the type number of the interface. Every method
|
||||||
return llvm.Value{}, err
|
// call on an interface will do a lookup which method to call.
|
||||||
}
|
// This is different from how the official Go compiler works, because of
|
||||||
itfTypeNum := c.getInterfaceType(expr.X.Type())
|
// heap allocation and because it's easier to implement, see:
|
||||||
return c.builder.CreateInsertValue(value, itfTypeNum, 0, ""), nil
|
// https://research.swtch.com/interfaces
|
||||||
|
return c.parseExpr(frame, expr.X)
|
||||||
case *ssa.ChangeType:
|
case *ssa.ChangeType:
|
||||||
return c.parseConvert(frame, expr.Type(), expr.X)
|
return c.parseConvert(frame, expr.Type(), expr.X)
|
||||||
case *ssa.Const:
|
case *ssa.Const:
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче