Skip to content

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