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 with consumption/inheritance in roles #4407

Merged
merged 2 commits into from
Jun 17, 2021

Conversation

vrurg
Copy link
Member

@vrurg vrurg commented Jun 17, 2021

Make the following two constructs possible:

role R1[::T] does T {}
role R2[::T] is T {}

These were assumed possible, according to a comment in ParametricRoleHOW
code. But a few final touches needed to make them possible:

  • traits must accept generics when applied to a parametric type
  • typechecks must be done against instantiated typeobjects too,
    including parents
  • additional validation for archetype of a consumed typeobject after
    instantiation since it bypassed trait validation

Spectests are passing.

@vrurg
Copy link
Member Author

vrurg commented Jun 17, 2021

I currently see this rather useful for cases like:

role R[::T Foo] is T { }
class C does R[FooChild] { }

which would certainly be better than something like:

role R[::T Foo] { }
class C does R[FooChild] is FooChild { }

Especially when R declared in a module.

@lizmat lizmat changed the title Support generics with consumtion/inheritance in roles Support generics with consumption/inheritance in roles Jun 17, 2021
Make the following two constructs possible:

    role R1[::T] does T {}
    role R2[::T] is T {}

These were assumed possible, according to a comment in ParametricRoleHOW
code. But a few final touches needed to make them possible:

- traits must accept generics when applied to a parametric type
- typechecks must be done against instantiated typeobjects too,
  including parents
- additional validation for archetype of a consumed typeobject after
  instantiation since it bypassed trait validation

Spectests are passing.
vrurg added a commit to vrurg/roast that referenced this pull request Jun 17, 2021
Test for cases:

    role R[::T] is T {}
    role R[::T] does T {}

In support of rakudo/rakudo#4407
Pre-cache `$_.HOW` where it's used more than once.

Also fix a typo in ParametricRoleHOW.
@vrurg vrurg force-pushed the allow-generic-inheritance branch from c8ac577 to 6e1cfe4 Compare June 17, 2021 20:53
@vrurg vrurg merged commit d881ac0 into rakudo:master Jun 17, 2021
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

Successfully merging this pull request may close these issues.

1 participant