liufengyun / gestalt

gestalt : portable and solid macros for Scala
https://github.com/scalacenter/macros
31 stars 3 forks source link

Quasiquotes: private and protected modifiers #26

Closed valdisxp1 closed 7 years ago

valdisxp1 commented 7 years ago

This macros fails when lifting the quasiquote:

class addFields extends StaticAnnotation {
  inline def apply(defn: Any): Any = meta {
    val q"class $name { ..$stats }" = defn
    val main = q"""
      ..$stats
      private def a = 1
      private[this] def b = 2
      private[pack] def c = 3

      protected def a1 = 1
      protected[this] def b1 = 2
      protected[pack] def c1 = 3
    """
    q"class $name { $main }"
  }
}

Cause:

//Quotes.scala
    case m.Mod.Private(within) =>
      // FIXME expected:  Mod.Private.apply(within: String) got: Mod.Private.apply(within: Tree)
      selectToolbox("Mod.Private").appliedTo(lift(within)) 
    case m.Mod.Protected(within) =>
      // FIXME expected:  Mod.Protected.apply(within: String) got: Mod.Private.apply(within: Tree)
      selectToolbox("Mod.Protected").appliedTo(lift(within)) 
liufengyun commented 7 years ago

This should be fixed by the latest PR.

valdisxp1 commented 7 years ago

Yes, it did fix the meta-type error. I an issue with private[this] and protected[this]. After #28 (merged) and #30 should work correctly.