]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/types2: remove Interface.Complete (cleanup)
authorRobert Griesemer <gri@golang.org>
Fri, 6 Aug 2021 01:33:22 +0000 (18:33 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 6 Aug 2021 20:34:54 +0000 (20:34 +0000)
Interface.Complete is not needed anymore. We can remove it in
types2 (and eventually make it an empty function in go/types,
where we must maintain the existing API).

Change-Id: I689f0d6f3a83997d8ca5bae773b9af0083d0bf4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/340255
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>
src/cmd/compile/internal/importer/iimport.go
src/cmd/compile/internal/noder/reader2.go
src/cmd/compile/internal/types2/interface.go
src/cmd/compile/internal/types2/issues_test.go

index 6dd8d595ae65e6865ab5662d409e8e5dfa364fc8..523b00313da619c328af44bda2fc57019ee059dd 100644 (file)
@@ -183,10 +183,6 @@ func ImportData(imports map[string]*types2.Package, data, path string) (pkg *typ
                p.doDecl(localpkg, name)
        }
 
-       for _, typ := range p.interfaceList {
-               typ.Complete()
-       }
-
        // record all referenced packages as imports
        list := append(([]*types2.Package)(nil), pkgList[1:]...)
        sort.Sort(byPath(list))
index fe1f329c822a8fb1467c0749f18dd454a2626e0f..5637196dc0eec7a161eb6cf001b3ba3d8c72aadc 100644 (file)
@@ -303,9 +303,7 @@ func (r *reader2) interfaceType() *types2.Interface {
                embeddeds[i] = r.typ()
        }
 
-       typ := types2.NewInterfaceType(methods, embeddeds)
-       typ.Complete()
-       return typ
+       return types2.NewInterfaceType(methods, embeddeds)
 }
 
 func (r *reader2) signature(recv *types2.Var) *types2.Signature {
index 89cf8465987b01fa062d1954c2913e73fd91362b..2617f748de6b6eefad5eca5dedfcba7609d97779 100644 (file)
@@ -100,25 +100,6 @@ func (t *Interface) IsComparable() bool { return t.typeSet().IsComparable() }
 // IsConstraint reports whether interface t is not just a method set.
 func (t *Interface) IsConstraint() bool { return !t.typeSet().IsMethodSet() }
 
-// Complete computes the interface's type set. It must be called by users of
-// NewInterfaceType and NewInterface after the interface's embedded types are
-// fully defined and before using the interface type in any way other than to
-// form other types. The interface must not contain duplicate methods or a
-// panic occurs. Complete returns the receiver.
-//
-// Deprecated: Type sets are now computed lazily, on demand; this function
-//             is only here for backward-compatibility. It does not have to
-//             be called explicitly anymore.
-func (t *Interface) Complete() *Interface {
-       // Some tests are still depending on the state change
-       // (string representation of an Interface not containing an
-       // /* incomplete */ marker) caused by the explicit Complete
-       // call, so we compute the type set eagerly here.
-       t.complete = true
-       t.typeSet()
-       return t
-}
-
 func (t *Interface) Underlying() Type { return t }
 func (t *Interface) String() string   { return TypeString(t, nil) }
 
index aafe8de3676efde8c56d81321865f915e33512af..9890b79323ac81dfe0347532b831b1cf2f635513 100644 (file)
@@ -402,8 +402,9 @@ func TestIssue28282(t *testing.T) {
        // create type interface { error }
        et := Universe.Lookup("error").Type()
        it := NewInterfaceType(nil, []Type{et})
-       it.Complete()
        // verify that after completing the interface, the embedded method remains unchanged
+       // (interfaces are "completed" lazily now, so the completion happens implicitly when
+       // accessing Method(0))
        want := et.Underlying().(*Interface).Method(0)
        got := it.Method(0)
        if got != want {