diff --git a/compiler.go b/compiler.go index 552cb589..40c68928 100644 --- a/compiler.go +++ b/compiler.go @@ -2279,16 +2279,10 @@ func (c *Compiler) parseConst(expr *ssa.Const) (llvm.Value, error) { if expr.Value != nil { return llvm.Value{}, errors.New("non-nil interface constant") } - itfTypeNum, ok := c.ir.TypeNum(expr.Type()) - if itfTypeNum >= 1<<16 { - return llvm.Value{}, errors.New("interface typecodes do not fit in a 16-bit integer") - } - if !ok { - panic("interface number is unknown") - } + // Create a generic nil interface with no dynamic type (typecode=0). fields := []llvm.Value{ - llvm.ConstInt(llvm.Int16Type(), uint64(itfTypeNum), false), - llvm.Undef(c.i8ptrType), + llvm.ConstInt(llvm.Int16Type(), 0, false), + llvm.ConstPointerNull(c.i8ptrType), } itf := llvm.ConstNamedStruct(c.mod.GetTypeByName("runtime._interface"), fields) return itf, nil diff --git a/passes.go b/passes.go index 2b2535b3..eb784f18 100644 --- a/passes.go +++ b/passes.go @@ -103,7 +103,7 @@ func (p *Program) AnalyseCallgraph() { // Find all types that are put in an interface. func (p *Program) AnalyseInterfaceConversions() { // Clear, if AnalyseTypes has been called before. - p.typesWithoutMethods = map[string]int{"interface{}": 0, "error": 1} + p.typesWithoutMethods = map[string]int{"nil": 0} p.typesWithMethods = map[string]*InterfaceType{} for _, f := range p.Functions {