summaryrefslogblamecommitdiff
path: root/test/files/run/t5905-features.scala
blob: a3848eef2ae99e6fd80be84062e12b543cf7cb73 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                                                  
                                                                                   



                                                                  

                                                                          

                   

                                                                                                                                       












                                                                                                                                                            
import tools.partest.DirectTest

// verify that all languageFeature names are accepted by -language
object Test extends DirectTest {
  override def code = "class Code { def f = (1 to 10) size }" // exercise a feature

  override def extraSettings = s"-usejavacp -d ${testOutput.path}"

  override def show() = {
    val global = newCompiler("-language:postfixOps", "-Ystop-after:typer")
    compileString(global)(code)
    import global._
    exitingTyper {
      //def isFeature(s: Symbol) = s.annotations.exists((a: AnnotationInfo) => a.tpe <:< typeOf[scala.annotation.meta.languageFeature])
      def isFeature(s: Symbol) = s hasAnnotation definitions.LanguageFeatureAnnot
      val langf  = definitions.languageFeatureModule.typeSignature
      val feats  = langf.declarations filter (s => isFeature(s)) map (_.name.decoded)
      val xmen   = langf.member(TermName("experimental")).typeSignature.declarations filter (s => isFeature(s)) map (s => s"experimental.${s.name.decoded}")
      val all    = (feats ++ xmen) mkString ","

      assert(feats.nonEmpty, "Test must find feature flags.")

      //dynamics,postfixOps,reflectiveCalls,implicitConversions,higherKinds,existentials,experimental.macros
      compile(s"-language:$all")
    }
  }
}