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

Support generic function declarations #3

Open
MaxDesiatov opened this issue May 31, 2019 · 0 comments
Open

Support generic function declarations #3

MaxDesiatov opened this issue May 31, 2019 · 0 comments
Assignees

Comments

@MaxDesiatov
Copy link
Owner

Inference and type checking within functions such as

func max<T: Comparable>(_ x: T, _ y: T) -> T {
  return x > y ? x : y
}

can be implemented with a creation of a "fake" concrete type T, which has all members of Comparable protocol copied into it. Then inference of func max could run as if T is a type constructor of a concrete type, not a generic parameter.

@MaxDesiatov MaxDesiatov self-assigned this Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant