milessabin/shapeless — pull request #19 by pufuwozu (2013-02-10 21:19:25+00:00)
Title: Evaluate expressions supplied to SNat macros

Relaxes constraint of requiring Constant nodes. Allows crazy things:

val x:SInt({(a:Int,b:Int,c:Int)=>a*a+b*b+c*c}.apply(3,4,5)) = 50

---
From #nescala!

I also incorporated @travisbrown's suggestion that we don't need 2 separate macro implementations for `implicitSNat` and `explicitSNat`. I tried it out like so and seemed to work fine:

scala> natToInt(1039)
1039
res2: Int = 1039

Strangely, code like the following breaks with a huge stack trace:

natToInt({(a:Int,b:Int,c:Int)=>a*a+b*b+c*c}.apply(3,4,5))

Scala bug?