diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 405657c84f..06e52c0c34 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -73,9 +73,11 @@ func (check *Checker) infer(pos token.Pos, tparams []*TypeName, params *Tuple, a // infer an untyped nil type as type parameter type. Ignore untyped // nil by making sure all default argument types are typed. if isTyped(targ) && !check.identical0(par.typ, targ, true, nil, targs) { - check.errorf(arg.pos(), "default type %s for %s does not match %s = %s", - Default(arg.typ), arg.expr, par.typ, check.subst(pos, par.typ, tparams, targs), - ) + // TODO(gri) see TODO comment above + // check.errorf(arg.pos(), "default type %s for %s does not match %s = %s", + // Default(arg.typ), arg.expr, par.typ, check.subst(pos, par.typ, tparams, targs), + // ) + check.errorf(arg.pos(), "default type %s for %s does not match %s", Default(arg.typ), arg.expr, par.typ) return nil } } diff --git a/src/go/types/lookup.go b/src/go/types/lookup.go index ab21d04c00..d30cb41f32 100644 --- a/src/go/types/lookup.go +++ b/src/go/types/lookup.go @@ -362,14 +362,14 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method, // does not instantiate the methods). // In order to compare the signatures, substitute the receiver // type parameters of ftyp with V's instantiation type arguments. - // This lazily instantiates the method f. - if Vn != nil { + // This lazily instantiates the signature of method f. + if Vn != nil && len(Vn.targs) > 0 { ftyp = check.subst(token.NoPos, ftyp, ftyp.rparams, Vn.targs).(*Signature) } // If the methods have type parameters we don't care whether they // are the same or not, as long as they match up. Use inference - // comparison in that case. + // comparison (provide non-nil tparams to identical0) in that case. // TODO(gri) is this always correct? what about type bounds? // (Alternative is to rename/subst type parameters and compare.) var tparams []Type