Skip to content

Allow None and Some to be inline parameters #5181

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

Merged
merged 1 commit into from
Oct 4, 2018

Conversation

nicolasstucki
Copy link
Contributor

Allow inline parameters to have type Option[T] for some inlinable T. It will allow know the value of a statically known Option[T] at macro expansion type (without TASTy reflection).

inline def foo(inline opt: Option[Int]): Int = ~impl(opt)
def impl(opt: Option[Int]): Expr[Int] = opt.getOrElse(-1).toExpr
foo(None) // ok
foo(Some(1)) // ok
foo(new Some(1)) // ok
foo(opt) // error
foo(Some(n)) // error

This is quite useful in combination with valueOpt[T].

This is a first step into knowing statically structured values. It will be extended in the future for tuples, lists and maybe a restricted subset of case classes.

@nicolasstucki
Copy link
Contributor Author

Rebased

@biboudis biboudis merged commit 42de57a into scala:master Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants