Skip to content

Commit 3beab0c

Browse files
committed
go/types, types2: add the Interface.MarkImplicit method
Add a new interface method, MarkImplicit, to allow marking interfaces as implicit from outside the type-checker. This is necessary so that we can capture the implicit bit in export data, and use it from importers. For #48424 For #49040 Change-Id: I999aba2a298f92432326d7ccbd87fe133a2e1a72 Reviewed-on: https://go-review.googlesource.com/c/go/+/357796 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 5a3d0f5 commit 3beab0c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface {
5454
return typ
5555
}
5656

57+
// MarkImplicit marks the interface t as implicit, meaning this interface
58+
// corresponds to a constraint literal such as ~T or A|B without explicit
59+
// interface embedding. MarkImplicit should be called before any concurrent use
60+
// of implicit interfaces.
61+
func (t *Interface) MarkImplicit() {
62+
t.implicit = true
63+
}
64+
5765
// NumExplicitMethods returns the number of explicitly declared methods of interface t.
5866
func (t *Interface) NumExplicitMethods() int { return len(t.methods) }
5967

src/go/types/interface.go

+8
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface {
7373
return typ
7474
}
7575

76+
// MarkImplicit marks the interface t as implicit, meaning this interface
77+
// corresponds to a constraint literal such as ~T or A|B without explicit
78+
// interface embedding. MarkImplicit should be called before any concurrent use
79+
// of implicit interfaces.
80+
func (t *Interface) MarkImplicit() {
81+
t.implicit = true
82+
}
83+
7684
// NumExplicitMethods returns the number of explicitly declared methods of interface t.
7785
func (t *Interface) NumExplicitMethods() int { return len(t.methods) }
7886

0 commit comments

Comments
 (0)