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

go/types: add IsAssignableTo predicate #5498

adonovan opened this issue May 17, 2013 · 2 comments

go/types: add IsAssignableTo predicate #5498

adonovan opened this issue May 17, 2013 · 2 comments


Copy link

Many clients will need something like this:

type Type interface {
    IsAssignableTo(Type) bool

This is a generalization of the Implements predicate defined thus:
  Implements(conc Type, iface *Interface) bool
in which you always have a concrete type and an interface.

FWIW, my code only needs the latter.  Specifically,

ssa/interp only need this method:
  func MissingMethod(conc types.Type, iface *types.Interface) *types.Method

ssa/pointer only needs this method:
  func ImplementsInterface(conc types.Type, iface *types.Interface) bool {
    return MissingMethod(conc, iface) == nil
Copy link

rsc commented May 24, 2013

Comment 1:

reflect already has this and calls it AssignableTo.

Copy link

Comment 2:

This was fixed with .
We may rename IsAssignableTo to IsAssignable in the future for consistency with reflect.

Status changed to Fixed.

@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.
None yet

No branches or pull requests

4 participants