ssa: fix map key has typeargs

This commit is contained in:
visualfc
2024-09-16 20:26:20 +08:00
parent dca028a84f
commit ce87f293aa
7 changed files with 1503 additions and 5 deletions

View File

@@ -1036,7 +1036,19 @@ func (p *context) patchType(typ types.Type) types.Type {
if pkg := o.Pkg(); typepatch.IsPatched(pkg) {
if patch, ok := p.patches[pkg.Path()]; ok {
if obj := patch.Types.Scope().Lookup(o.Name()); obj != nil {
return p.prog.Type(obj.Type(), llssa.InGo).RawType()
otyp := obj.Type()
if tp := t.TypeArgs(); tp != nil {
targs := make([]types.Type, tp.Len())
for i := 0; i < tp.Len(); i++ {
targs[i] = tp.At(i)
}
var err error
otyp, err = types.Instantiate(nil, obj.Type(), targs, true)
if err != nil {
panic(fmt.Errorf("patchType error: %v", err))
}
}
return p.prog.Type(otyp, llssa.InGo).RawType()
}
}
}