Created
November 8, 2013 21:00
-
-
Save xuwei-k/7377625 to your computer and use it in GitHub Desktop.
compile time check scala version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_45). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import scala.language.experimental.macros | |
import scala.language.experimental.macros | |
scala> import scala.reflect.macros.Context | |
import scala.reflect.macros.Context | |
scala> def require2_10_4_impl(c: Context): c.Expr[Unit] = { | |
| import c.universe._ | |
| if(scala.util.Properties.versionNumberString != "2.10.4"){ | |
| c.abort(c.enclosingPosition, "ヽ(`Д´)ノ SI-6240") | |
| } | |
| c.Expr(Literal(Constant(()))) | |
| } | |
require2_10_4_impl: (c: scala.reflect.macros.Context)c.Expr[Unit] | |
scala> def require2_10_4: Unit = macro require2_10_4_impl | |
require2_10_4: Unit | |
scala> require2_10_4 | |
<console>:12: error: ヽ(`Д´)ノ SI-6240 | |
require2_10_4 | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment