]> Cypherpunks repositories - gostls13.git/commit
go/types: NewInterface/NewInterfaceType complete empty interfaces
authorRobert Griesemer <gri@golang.org>
Thu, 22 Aug 2019 21:47:01 +0000 (14:47 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 26 Aug 2019 16:36:22 +0000 (16:36 +0000)
commit82d6e2eab8ea12962f2ad5f1d446350a7572d57c
treeec288f16dbade38e5bdf148807a44957096dac9a
parenta80c5f0588e3835ff37c45a15d179571d9e403e0
go/types: NewInterface/NewInterfaceType complete empty interfaces

When creating a new interface via the exported API calls, a shared
empty and completed Interface value is returned if there are no
methods or embedded interfaces. This is a minor optimization and
matches the internal behavior when creating empty interfaces.

Since calling Interface.Complete is idempotent, and since there
are no other legitimate ways to create Interface values externally
but via NewInterface/NewInterfaceType calls, and completed Interfaces
are considered "immutable", this change is not expected to affect
clients. The only observable behavior that changed is the string
value for empty interfaces created via the above API calls; those
empty interfaces now don't show "incomplete" anymore even before
Interface.Complete is called. Except in special test cases, this
behavior is unlikely to affect clients.

Change-Id: Idf7f2cd112241c5b81a43b4544bbe3f2e003d8d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/191417
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/go/types/type.go
src/go/types/typestring_test.go