Skip to content

No way to tell if TermParamClause is marked as using #12021

Closed
@japgolly

Description

@japgolly

Compiler version

Both:

  • 3.0.0-RC1
  • 3.0.1-RC1-bin-20210406-b0061c4-NIGHTLY

Minimized code

import scala.quoted.*

inline def inspect[A]: Unit =
  ${ inspect2[A] }

def inspect2[A: Type](using Quotes): Expr[Unit] = {
  import quotes.reflect.*

  val DefDef(_, List(Nil, ps: TermParamClause), _, _) =
    TypeRepr.of[A].typeSymbol.primaryConstructor.tree

  val names = ps.params.map(p => s"${p.name}: ${p.tpt.show}").mkString("(", ", ", ")")

  println(s"${Type.show[A]}: $names isImplicit = ${ps.isImplicit}")

  '{()}
}

class X1(implicit i: Int)
class X2(using i: Int)

def test = {
  inspect[X1]
  inspect[X2]
}

Output

X1: (i: scala.Int) isImplicit = true
X2: (i: scala.Int) isImplicit = false

Expectation

Currently there's no way to tell whether an parameter clause is marked with using or not.

I expect one of the following. Either:

  1. TermParamClause should return true for isImplicit in the X2 case
  2. TermParamClause should have a isGiven method

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions