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

Closed
adonovan opened this issue May 17, 2013 · 2 comments
Closed

go/types: add IsAssignableTo predicate #5498

adonovan opened this issue May 17, 2013 · 2 comments
Assignees

Comments

@adonovan
Copy link
Contributor

@adonovan adonovan commented May 17, 2013

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
  }
@rsc
Copy link
Contributor

@rsc rsc commented May 24, 2013

Comment 1:

reflect already has this and calls it AssignableTo.

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Jul 15, 2013

Comment 2:

This was fixed with https://golang.org/cl/11189043/ .
We may rename IsAssignableTo to IsAssignable in the future for consistency with reflect.

Status changed to Fixed.

Loading

@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants