Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/api: interfaces with unexported methods can be extended #4061

Closed
rsc opened this issue Sep 11, 2012 · 1 comment
Closed

cmd/api: interfaces with unexported methods can be extended #4061

rsc opened this issue Sep 11, 2012 · 1 comment
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Sep 11, 2012

If I add a new method to reflect.Type the api tool rejects it:

+pkg reflect, type Type interface { Align, AssignableTo, Bits, ChanDir, ConvertibleTo,
Elem, Field, FieldAlign, FieldByIndex, FieldByName, FieldByNameFunc, Implements, In,
IsVariadic, Key, Kind, Len, Method, MethodByName, Name, NumField, NumIn, NumMethod,
NumOut, Out, PkgPath, Size, String }
-pkg reflect, type Type interface { Align, AssignableTo, Bits, ChanDir, Elem, Field,
FieldAlign, FieldByIndex, FieldByName, FieldByNameFunc, Implements, In, IsVariadic, Key,
Kind, Len, Method, MethodByName, Name, NumField, NumIn, NumMethod, NumOut, Out, PkgPath,
Size, String }

However, this is okay as long as all the implementations in package reflect have been
updated to continue to implement the new interfaces, because Type has an unexported
method (or more), so there is no possibility that code outside reflect is trying to
implement this interface and will break because of the new method. Additions are okay,
deletions are not.

I suspect that the easiest fix is to say that for interfaces with unexported methods,
you list the exported ones one per line like we do for struct fields:

pkg reflect, type Type interface, method Align
...

As a counter-example test case, io.Reader would continue to use the existing 1-line
format.
@rsc
Copy link
Contributor Author

rsc commented Sep 18, 2012

Comment 1:

This issue was closed by revision a29f313.

Status changed to Fixed.

@rsc rsc added fixed labels Sep 18, 2012
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants