]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: add the Interface.MarkImplicit method
authorRobert Findley <rfindley@google.com>
Thu, 21 Oct 2021 22:59:10 +0000 (18:59 -0400)
committerRobert Findley <rfindley@google.com>
Thu, 21 Oct 2021 23:48:53 +0000 (23:48 +0000)
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 <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/types2/interface.go
src/go/types/interface.go

index 0704628dc69a2987ddede660a337099d3d0ebe59..048fcab024efe9813b8b8adcff775fa0da147742 100644 (file)
@@ -54,6 +54,14 @@ func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface {
        return typ
 }
 
+// MarkImplicit marks the interface t as implicit, meaning this interface
+// corresponds to a constraint literal such as ~T or A|B without explicit
+// interface embedding. MarkImplicit should be called before any concurrent use
+// of implicit interfaces.
+func (t *Interface) MarkImplicit() {
+       t.implicit = true
+}
+
 // NumExplicitMethods returns the number of explicitly declared methods of interface t.
 func (t *Interface) NumExplicitMethods() int { return len(t.methods) }
 
index 2f4f10d45fa19cadb44a3eeb1afe0ea5d2f4d00e..3d5573373f1431e62e5cc1123967ca883867d343 100644 (file)
@@ -73,6 +73,14 @@ func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface {
        return typ
 }
 
+// MarkImplicit marks the interface t as implicit, meaning this interface
+// corresponds to a constraint literal such as ~T or A|B without explicit
+// interface embedding. MarkImplicit should be called before any concurrent use
+// of implicit interfaces.
+func (t *Interface) MarkImplicit() {
+       t.implicit = true
+}
+
 // NumExplicitMethods returns the number of explicitly declared methods of interface t.
 func (t *Interface) NumExplicitMethods() int { return len(t.methods) }