Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Allow some kind of TraitAnnotation that is not based on reflection #132

Open
Lumintorious opened this issue Aug 23, 2020 · 0 comments
Open

Comments

@Lumintorious
Copy link

Lumintorious commented Aug 23, 2020

Have a annotation type like TraitAnnotation that when is annotating an object, that object insead behaves like it's extending the trait. This would be useful for marker traits and for readability without hindering performance with reflections(this can all happen at compile time).

Example:

trait Identifiable(val id: String) extends scala.something.TraitAnnotation

trait RequestSolver:
    this: Identifiable =>
    def resolve(): Unit


@Identifiable("/index")
object MainPage extends RequestSolver:
    def resolve(): Unit = ???

that gets compiled to

object MainPage extends RequestSolver with Identifiable("/index"):
    def resolve(): Unit = ???

and can be used normally:

if(url.toString == MainPage.id) then MainPage.resolve()
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant