Skip to content
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

Use new given extension syntax in scala.quoted #7257

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion community-build/community-projects/scalatest
Submodule scalatest updated 22 files
+1 −1 common-test.dotty/src/main/scala/org/scalatest/LineNumberHelper.scala
+7 −7 project/GenAnyVals.scala
+1 −1 project/GenFactoriesDotty.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/BooleanMacro.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/Requirements.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/Snapshots.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/anyvals/CompileTimeAssertions.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/anyvals/NumericStringMacro.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/anyvals/PercentageIntMacros.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/anyvals/RegexStringMacro.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/source/Position.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/source/TypeInfo.scala
+1 −1 scalactic.dotty/src/main/scala/org/scalactic/source/TypeInfoMacro.scala
+2 −2 scalatest.dotty/src/main/scala/org/scalatest/Assertions.scala
+1 −1 scalatest.dotty/src/main/scala/org/scalatest/AssertionsMacro.scala
+1 −1 scalatest.dotty/src/main/scala/org/scalatest/CompileMacro.scala
+1 −1 scalatest.dotty/src/main/scala/org/scalatest/DiagrammedAssertionsMacro.scala
+1 −1 scalatest.dotty/src/main/scala/org/scalatest/diagrams/Diagrams.scala
+1 −1 scalatest.dotty/src/main/scala/org/scalatest/diagrams/DiagramsMacro.scala
+1 −1 scalatest.dotty/src/main/scala/org/scalatest/expectations/ExpectationsMacro.scala
+1 −1 scalatest.dotty/src/main/scala/org/scalatest/matchers/MatchPatternMacro.scala
+1 −1 scalatest.dotty/src/main/scala/org/scalatest/matchers/TypeMatcherMacro.scala
2 changes: 1 addition & 1 deletion compiler/test-resources/repl-macros/i5551
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scala> import scala.quoted._
scala> import scala.quoted.{_, given}
scala> def assertImpl(expr: Expr[Boolean])(given qctx: QuoteContext) = '{ if !($expr) then throw new AssertionError("failed assertion")}
def assertImpl
(expr: quoted.Expr[Boolean])
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/reference/metaprogramming/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ a boolean expression tree as argument. `assertImpl` evaluates the expression and
prints it again in an error message if it evaluates to `false`.

```scala
import scala.quoted._
import scala.quoted.{_, given}

inline def assert(expr: => Boolean): Unit =
${ assertImpl('expr) }
Expand Down Expand Up @@ -205,7 +205,7 @@ phase-correct. If that was not the case, the phase inconsistency for
Consider the following implementation of a staged interpreter that implements
a compiler through staging.
```scala
import scala.quoted._
import scala.quoted.{_, given}

enum Exp {
case Num(n: Int)
Expand All @@ -224,7 +224,7 @@ Here’s a compiler that maps an expression given in the interpreted
language to quoted Scala code of type `Expr[Int]`.
The compiler takes an environment that maps variable names to Scala `Expr`s.
```scala
import given scala.quoted._
import scala.quoted.{_, given}

def compile(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match {
case Num(n) =>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/metaprogramming/tasty-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ parameter of type `scala.quoted.QuoteContext` and import `tasty._` from it in
the scope where it is used.

```scala
import scala.quoted._
import scala.quoted.{_, given}

inline def natConst(x: => Int): Int = ${natConstImpl('{x})}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package dotty.internal

import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.matching._
import reflect._

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.compiletime

import scala.quoted._
import scala.quoted.{_, given}

package object testing {

Expand Down
4 changes: 3 additions & 1 deletion library/src-bootstrapped/scala/quoted/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package object quoted {
given autoToExpr[T](given Liftable[T], QuoteContext): Conversion[T, Expr[T]] = _.toExpr
}

implicit object ExprOps {
given ExprOps: {

/** Lift a value into an expression containing the construction of that value */
def (x: T) toExpr[T: Liftable](given QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x)

/** Lifts this sequence of expressions into an expression of a sequence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package dotty.internal

import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.matching._
import reflect._

Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/internal/Quoted.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scala.internal

import scala.annotation.{Annotation, compileTimeOnly}
import scala.quoted._
import scala.quoted.{_, given}

object Quoted {

Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/internal/quoted/Expr.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.internal.quoted

import scala.quoted._
import scala.quoted.{_, given}

object Expr {

Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/internal/quoted/Matcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package scala.internal.quoted

import scala.annotation.internal.sharable

import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.matching.Bind

private[quoted] object Matcher {
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/internal/quoted/Type.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.internal.quoted

import scala.quoted._
import scala.quoted.{_, given}

object Type {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hello

// Import `Expr` and some extension methods
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.staging.{run, Toolbox}

object Main {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package hello
import org.junit.Test

// Import Expr and some extension methods
import scala.quoted._
import scala.quoted.{_, given}

class Tests {

Expand Down
2 changes: 1 addition & 1 deletion staging/src/scala/quoted/staging/QuoteDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dotty.tools.dotc.tastyreflect.ReflectionImpl
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory, VirtualDirectory}
import dotty.tools.repl.AbstractFileClassLoader
import dotty.tools.dotc.reporting._
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.staging.Toolbox
import java.net.URLClassLoader

Expand Down
2 changes: 1 addition & 1 deletion staging/test-resources/repl-staging/i6007
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scala> import scala.quoted._
scala> import scala.quoted.{_, given}
scala> import scala.quoted.staging._
scala> implicit def toolbox: Toolbox = Toolbox.make(getClass.getClassLoader)
def toolbox: quoted.staging.Toolbox
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.autolift.given

object Macros {
Expand Down
2 changes: 1 addition & 1 deletion tests/disabled/pos/quote-whitebox/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import scala.quoted._
import scala.quoted.{_, given}

object Macro {

Expand Down
2 changes: 1 addition & 1 deletion tests/disabled/run/i4803d/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object PowerMacro {
def powerCode(x: Expr[Double], n: Long): Expr[Double] =
Expand Down
2 changes: 1 addition & 1 deletion tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.tasty.Tasty
import scala.quoted.autolift.given

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-1/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.matching._

inline def f: Any = ${ fImpl }
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-2/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.matching._

inline def f: Any = ${ fImpl }
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-3/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.matching._

inline def f: Any = ${ fImpl }
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i6432/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.autolift.given
import scala.quoted.matching._

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i6432b/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.autolift.given
import scala.quoted.matching._

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i6976/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package playground

import scala.quoted._, scala.quoted.matching._
import scala.quoted.{_, given}, scala.quoted.matching._
import scala.quoted.given
import scala.tasty._

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/inline-case-objects/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import scala.quoted._
import scala.quoted.{_, given}

object Macros {
def impl(foo: Any)(given QuoteContext): Expr[String] = foo.getClass.getCanonicalName.toExpr
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.autolift.given

object E {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/inline-option/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import scala.quoted._
import scala.quoted.{_, given}

object Macro {
def impl(opt: Option[Int])(given QuoteContext): Expr[Int] = opt match {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/inline-tuples-1/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.autolift.given

object Macros {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/macros-in-same-project-1/Foo.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Foo {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/macros-in-same-project-2/Foo.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Foo {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/macros-in-same-project-3/Bar.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Bar {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/macros-in-same-project-3/Foo.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Foo {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/macros-in-same-project-4/Bar.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Bar {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/macros-in-same-project-4/Foo.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Foo {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-complex-top-splice.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Test.impl

import scala.quoted._
import scala.quoted.{_, given}

object Test {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-interpolator-core-old.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.autolift.given

// This test checks the correct interpretation of the inlined value class
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-macro-complex-arg-0.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Macros {
inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i + 1, 'j) } // error: i + 1 is not a parameter or field reference
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-macro-splice.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.autolift.given

object Test {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-pcp-in-arg.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Foo {
inline def foo(x: Int): Int = ${ bar('{ 'x; x }) } // error
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-splice-interpret-1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import scala.quoted._
import scala.quoted.{_, given}

object Macros {
inline def isZero(inline n: Int): Boolean = ${
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-this-b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

class Foo {
inline def k(): Unit = ${ Foo.impl[Any](this) } // error
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-this.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

class Foo {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-whitebox/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Macros {
inline def defaultOf(inline str: String) <: Any = ${ defaultOfImpl(str) }
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/splice-in-top-level-splice-1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.quoted.autolift.given

object Foo {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/splice-in-top-level-splice-2.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Foo {
inline def foo(): Int = ${$x} // error
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/tasty-macro-assert-1/quoted_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Asserts {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/tasty-macro-assert-2/quoted_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Asserts {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/tasty-macro-error/quoted_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Macros {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/tasty-macro-positions/quoted_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}

object Macros {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.language.implicitConversions

object Macro {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.quoted._
import scala.quoted.{_, given}
import scala.language.implicitConversions

object Macro {
Expand Down
Loading