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 generics in traits #68

Open
soc opened this issue Nov 5, 2022 · 0 comments
Open

support generics in traits #68

soc opened this issue Nov 5, 2022 · 0 comments
Labels
enhancement improving existing functionality good first issue good for newcomers typer anything related to the typechecker and the typesystem

Comments

@soc
Copy link
Collaborator

soc commented Nov 5, 2022

Consider:

@pub trait Iterator {
  fun next(): Option[Int32]; // this should be made generic
}

Ideally we would have:

@pub trait Iterator[T] {
  fun next(): Option[T];
}

Which compiles, but a trait impls like ...

impl Iterator[Int32] for NoInt32Iterator {
  fun next(): Option[Int32] = None[Int32];
}

... fails compilation with:

return types `Option[Int32]` and `Option[T]` do not match

Feels like we forget specializing the return type.

@soc soc added this to the 1.0 – polishing milestone Nov 5, 2022
@soc soc added enhancement improving existing functionality good first issue good for newcomers typer anything related to the typechecker and the typesystem labels Nov 6, 2022
@soc soc changed the title support generics traits support generics in traits Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improving existing functionality good first issue good for newcomers typer anything related to the typechecker and the typesystem
Projects
None yet
Development

No branches or pull requests

1 participant