diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go index 834a25066b..3ba53052d7 100644 --- a/src/cmd/compile/internal/types2/named.go +++ b/src/cmd/compile/internal/types2/named.go @@ -113,6 +113,9 @@ func (t *Named) SetUnderlying(underlying Type) { panic("underlying type must not be *Named") } t.resolve(nil).underlying = underlying + if t.fromRHS == nil { + t.fromRHS = underlying // for cycle detection + } } // AddMethod adds method m unless it is already in the method list. diff --git a/src/go/types/named.go b/src/go/types/named.go index 6c77146485..f0c22d29e3 100644 --- a/src/go/types/named.go +++ b/src/go/types/named.go @@ -115,6 +115,9 @@ func (t *Named) SetUnderlying(underlying Type) { panic("underlying type must not be *Named") } t.resolve(nil).underlying = underlying + if t.fromRHS == nil { + t.fromRHS = underlying // for cycle detection + } } // AddMethod adds method m unless it is already in the method list.