aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/builtins.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-06-17 17:49:15 -0700
committerRobert Griesemer <gri@golang.org>2021-06-30 18:58:34 +0000
commit4b5fdb0b7a362cb6fa6ad551757104e490483121 (patch)
treea2d35fe408f7c5fb8d2fd8836481a23d023844c3 /src/cmd/compile/internal/types2/builtins.go
parentf503740ccf6302ed13c7722ea50c6880a17703fb (diff)
downloadgo-4b5fdb0b7a362cb6fa6ad551757104e490483121.tar.gz
go-4b5fdb0b7a362cb6fa6ad551757104e490483121.zip
[dev.typeparams] cmd/compile/internal/types2: introduce type set abstraction for interfaces
With this change, interfaces are "completed" on-demand, when needed, and the respective information (set of all methods, type constraints) is recorded in a new typeSet data structure. As a consequence, interfaces don't need to be explicitly completed anymore and (internal) uses of interfaces have become much simpler. This change also introduces a new field Interface.complete to indicate that all methods and embedded elements have been set up. This prevent the computation and recording (!) of a partial type set for erroneous programs (if we compute the partial type set and store it, subsequent type set accesses use the wrong type set which may lead to follow-on errors). Change-Id: I1ffc907f7d0fb93b3e987fe5ff9c6fa5cae00d7f Reviewed-on: https://go-review.googlesource.com/c/go/+/329309 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/builtins.go')
-rw-r--r--src/cmd/compile/internal/types2/builtins.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go
index 8f2d849ef5..ffe872e7ab 100644
--- a/src/cmd/compile/internal/types2/builtins.go
+++ b/src/cmd/compile/internal/types2/builtins.go
@@ -783,7 +783,7 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type {
tpar := NewTypeName(nopos, check.pkg, "<type parameter>", nil)
ptyp := check.NewTypeParam(tpar, 0, &emptyInterface) // assigns type to tpar as a side-effect
tsum := newUnion(rtypes, tildes)
- ptyp.bound = &Interface{allMethods: markComplete, allTypes: tsum}
+ ptyp.bound = &Interface{complete: true, tset: &TypeSet{types: tsum}}
return ptyp
}