Skip to content

Instantly share code, notes, and snippets.

@dwijnand
Last active April 11, 2018 16:57
Show Gist options
  • Save dwijnand/13b07e9f749f318602887edeb32603c1 to your computer and use it in GitHub Desktop.
Save dwijnand/13b07e9f749f318602887edeb32603c1 to your computer and use it in GitHub Desktop.

how many args and which types does this class take?

without "dangling parens"

  private[this] class ChangeOwnerAndModuleClassTraverser(
      oldowner: global.Symbol,
      newowner: global.Symbol)
      extends global.ChangeOwnerTraverser(oldowner, newowner) {
    override def traverse(tree: global.Tree): Unit = {
      tree match {

with "dangling parens"

  private[this] class ChangeOwnerAndModuleClassTraverser(
      oldowner: global.Symbol,
      newowner: global.Symbol
  ) extends global.ChangeOwnerTraverser(oldowner, newowner) {
    override def traverse(tree: global.Tree): Unit = {
      tree match {

what's the result type of this method?

without "dangling parens"

   * Typically, `f` is a `Select` or `Ident`.
   * The wrapper is replaced with the result of `subWrapper(<Type of T>, <Tree of v>, <wrapper Tree>)`
   */
  def transformWrappers(
      t: Tree,
      subWrapper: (String, Type, Tree, Tree) => Converted[ctx.type]): Tree = {
    // the main tree transformer that replaces calls to InputWrapper.wrap(x) with
    //  plain Idents that reference the actual input value
    object appTransformer extends Transformer {

with "dangling parens"

   * Typically, `f` is a `Select` or `Ident`.
   * The wrapper is replaced with the result of `subWrapper(<Type of T>, <Tree of v>, <wrapper Tree>)`
   */
  def transformWrappers(
      t: Tree,
      subWrapper: (String, Type, Tree, Tree) => Converted[ctx.type]
  ): Tree = {
    // the main tree transformer that replaces calls to InputWrapper.wrap(x) with
    //  plain Idents that reference the actual input value
    object appTransformer extends Transformer {

which callsite style do you prefer?

without "dangling parens"

private[this] def makeKList(
    revInputs: Inputs[c.universe.type],
    klist: Tree,
    klistType: Type): Tree =
  revInputs match {
    case in :: tail =>
      val next = ApplyTree(
        TypeApply(
          Ident(kcons),
          TypeTree(in.tpe) :: TypeTree(klistType) :: TypeTree(mTC) :: Nil),
        in.expr :: klist :: Nil)
      makeKList(tail, next, appliedType(kconsTC, in.tpe :: klistType :: mTC :: Nil))
    case Nil => klist
  }

with "dangling parens"

private[this] def makeKList(
    revInputs: Inputs[c.universe.type],
    klist: Tree,
    klistType: Type
): Tree =
  revInputs match {
    case in :: tail =>
      val next = ApplyTree(
        TypeApply(
          Ident(kcons),
          TypeTree(in.tpe) :: TypeTree(klistType) :: TypeTree(mTC) :: Nil
        ),
        in.expr :: klist :: Nil
      )
      makeKList(tail, next, appliedType(kconsTC, in.tpe :: klistType :: mTC :: Nil))
    case Nil => klist
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment