Skip to content

Commit 7520c08

Browse files
committed
go/types, types2: in SetUnderlying, set Named.fromRHS if not set yet
This is necessary for cycle detection over imported types whose underlying types are set by importers with SetUnderlying. Preparation for fixing issue #48962. Change-Id: I3218cda7feb06440fdb8345c94bcaa5f7d64e94e Reviewed-on: https://go-review.googlesource.com/c/go/+/379694 Trust: Robert Griesemer <[email protected]> Run-TryBot: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 9dfd458 commit 7520c08

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/cmd/compile/internal/types2/named.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ func (t *Named) SetUnderlying(underlying Type) {
113113
panic("underlying type must not be *Named")
114114
}
115115
t.resolve(nil).underlying = underlying
116+
if t.fromRHS == nil {
117+
t.fromRHS = underlying // for cycle detection
118+
}
116119
}
117120

118121
// AddMethod adds method m unless it is already in the method list.

src/go/types/named.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ func (t *Named) SetUnderlying(underlying Type) {
115115
panic("underlying type must not be *Named")
116116
}
117117
t.resolve(nil).underlying = underlying
118+
if t.fromRHS == nil {
119+
t.fromRHS = underlying // for cycle detection
120+
}
118121
}
119122

120123
// AddMethod adds method m unless it is already in the method list.

0 commit comments

Comments
 (0)