@@ -329,7 +329,7 @@ func (c *compilerContext) getInterfaceMethodSet(typ types.Type) llvm.Value {
329329// getMethodSignatureName returns a unique name (that can be used as the name of
330330// a global) for the given method.
331331func (c * compilerContext ) getMethodSignatureName (method * types.Func ) string {
332- signature := methodSignature (method )
332+ signature := c . methodSignature (method )
333333 var globalName string
334334 if token .IsExported (method .Name ()) {
335335 globalName = "reflect/methods." + signature
@@ -572,16 +572,16 @@ func (c *compilerContext) getInterfaceInvokeWrapper(fn *ssa.Function, llvmFn llv
572572//
573573// String() string
574574// Read([]byte) (int, error)
575- func methodSignature (method * types.Func ) string {
576- return method .Name () + signature (method .Type ().(* types.Signature ))
575+ func ( c * compilerContext ) methodSignature (method * types.Func ) string {
576+ return method .Name () + c . signature (method .Type ().(* types.Signature ))
577577}
578578
579579// Make a readable version of a function (pointer) signature.
580580// Examples:
581581//
582582// () string
583583// (string, int) (int, error)
584- func signature (sig * types.Signature ) string {
584+ func ( c * compilerContext ) signature (sig * types.Signature ) string {
585585 s := ""
586586 if sig .Params ().Len () == 0 {
587587 s += "()"
@@ -591,29 +591,29 @@ func signature(sig *types.Signature) string {
591591 if i > 0 {
592592 s += ", "
593593 }
594- s += emptyInterfaceToAny (sig .Params ().At (i ).Type ().String ())
594+ s += c . emptyInterfaceToAny (sig .Params ().At (i ).Type ().String ())
595595 }
596596 s += ")"
597597 }
598598 if sig .Results ().Len () == 0 {
599599 // keep as-is
600600 } else if sig .Results ().Len () == 1 {
601- s += " " + emptyInterfaceToAny (sig .Results ().At (0 ).Type ().String ())
601+ s += " " + c . emptyInterfaceToAny (sig .Results ().At (0 ).Type ().String ())
602602 } else {
603603 s += " ("
604604 for i := 0 ; i < sig .Results ().Len (); i ++ {
605605 if i > 0 {
606606 s += ", "
607607 }
608- s += emptyInterfaceToAny (sig .Results ().At (i ).Type ().String ())
608+ s += c . emptyInterfaceToAny (sig .Results ().At (i ).Type ().String ())
609609 }
610610 s += ")"
611611 }
612612 return s
613613}
614614
615- func emptyInterfaceToAny (typ string ) string {
616- if typ == "interface{}" {
615+ func ( c * compilerContext ) emptyInterfaceToAny (typ string ) string {
616+ if c . GoMinorVersion >= 18 && typ == "interface{}" {
617617 return "any"
618618 }
619619
0 commit comments