Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
japgolly opened this issue Apr 8, 2021 · 2 comments · Fixed by #12025
Closed

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

japgolly opened this issue Apr 8, 2021 · 2 comments · Fixed by #12025
Milestone

Comments

@japgolly
Copy link
Contributor

japgolly commented Apr 8, 2021

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
@nicolasstucki
Copy link
Contributor

In theory, we should have returned isImplicit = true for both cases.

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Apr 8, 2021

We should have isGiven as proposed and change the documentation of isImplicit.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 8, 2021
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 9, 2021
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 9, 2021
michelou pushed a commit to michelou/scala3 that referenced this issue Apr 9, 2021
michelou pushed a commit to michelou/scala3 that referenced this issue Apr 14, 2021
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants