Skip to content

Commit

Permalink
Tag experimental API tests (#19811)
Browse files Browse the repository at this point in the history
Add explicitly `-experimental -Yno-experimental` to tests that use
definitions that are `@experimental` in the standard library.
`-Yno-experimental` disables the experimental mode from nightly builds
and `-experimental` adds `@experimental` to all top-level definitions.

This is in preparation of #19760 and the disabling of experimental mode
by default in nightly builds. When nighly experimental mode will be
disabled we will be able to drop the `-Yno-experimental`.

These tests are for 
* `scala.annotation.MacroAnnotation`
* `scala.annotation.MainAnnotation`
* `scala.annotation.newMain`
* `scala.util.TupledFunction`
* Expreminetal definitions in `scala.quoted.Quotes`
  • Loading branch information
nicolasstucki authored Feb 29, 2024
2 parents 6b52789 + e746116 commit 929714c
Show file tree
Hide file tree
Showing 144 changed files with 244 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tests/neg-macros/i18677-a.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
|The tree does not conform to the compiler's tree invariants.
|
|Macro was:
|@scala.annotation.internal.SourceFile("tests/neg-macros/i18677-a/Test_2.scala") @extendFoo class AFoo()
|@scala.annotation.internal.SourceFile("tests/neg-macros/i18677-a/Test_2.scala") @scala.annotation.experimental @extendFoo class AFoo()
|
|The macro returned:
|@scala.annotation.internal.SourceFile("tests/neg-macros/i18677-a/Test_2.scala") @extendFoo class AFoo() extends Foo
|@scala.annotation.internal.SourceFile("tests/neg-macros/i18677-a/Test_2.scala") @scala.annotation.experimental @extendFoo class AFoo() extends Foo
|
|Error:
|assertion failed: Parents of class symbol differs from the parents in the tree for class AFoo
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i18677-a/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using -expermiental
//> using options -experimental -Yno-experimental

import annotation.MacroAnnotation
import quoted.*
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i18677-a/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using -expermiental
//> using options -experimental -Yno-experimental

@extendFoo
class AFoo // error
4 changes: 2 additions & 2 deletions tests/neg-macros/i18677-b.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
|The tree does not conform to the compiler's tree invariants.
|
|Macro was:
|@scala.annotation.internal.SourceFile("tests/neg-macros/i18677-b/Test_2.scala") @extendFoo class AFoo()
|@scala.annotation.internal.SourceFile("tests/neg-macros/i18677-b/Test_2.scala") @scala.annotation.experimental @extendFoo class AFoo()
|
|The macro returned:
|@scala.annotation.internal.SourceFile("tests/neg-macros/i18677-b/Test_2.scala") @extendFoo class AFoo() extends Foo
|@scala.annotation.internal.SourceFile("tests/neg-macros/i18677-b/Test_2.scala") @scala.annotation.experimental @extendFoo class AFoo() extends Foo
|
|Error:
|assertion failed: Parents of class symbol differs from the parents in the tree for class AFoo
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i18677-b/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using -expermiental
//> using options -experimental -Yno-experimental

import annotation.MacroAnnotation
import quoted.*
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i18677-b/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using -expermiental
//> using options -experimental -Yno-experimental

@extendFoo
class AFoo // error
2 changes: 2 additions & 0 deletions tests/neg-macros/newClassExtendsNoParents/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.quoted.*

inline def makeClass(inline name: String): Any = ${ makeClassExpr('name) }
Expand Down
2 changes: 2 additions & 0 deletions tests/neg-macros/newClassExtendsNoParents/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//> using options -experimental -Yno-experimental

def test: Any = makeClass("foo") // error
2 changes: 2 additions & 0 deletions tests/neg-macros/newClassExtendsOnlyTrait/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.quoted.*

inline def makeClass(inline name: String): Foo = ${ makeClassExpr('name) }
Expand Down
2 changes: 2 additions & 0 deletions tests/neg-macros/newClassExtendsOnlyTrait/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//> using options -experimental -Yno-experimental

def test: Foo = makeClass("foo") // error
2 changes: 2 additions & 0 deletions tests/pos-macros/annot-in-object/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/pos-macros/annot-in-object/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@Foo.void
@Foo.Bar.void
def test = 0
2 changes: 2 additions & 0 deletions tests/pos-macros/annot-suspend/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/pos-macros/annot-suspend/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
//> using options -experimental -Yno-experimental

@void
def test = 0
2 changes: 2 additions & 0 deletions tests/pos-macros/annot-then-inline/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/pos-macros/annot-then-inline/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
//> using options -experimental -Yno-experimental

@useInlinedIdentity
def test = 0
2 changes: 1 addition & 1 deletion tests/pos-macros/i15413/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Werror -WunstableInlineAccessors
//> using options -experimental -Yno-experimental -Werror -WunstableInlineAccessors

import scala.quoted.*
import scala.annotation.publicInBinary
Expand Down
2 changes: 2 additions & 0 deletions tests/pos-macros/i15413/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
//> using options -experimental -Yno-experimental

def test =
new Macro().foo
2 changes: 1 addition & 1 deletion tests/pos-macros/i15413b/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Werror -WunstableInlineAccessors
//> using options -experimental -Yno-experimental -Werror -WunstableInlineAccessors

package bar

Expand Down
2 changes: 2 additions & 0 deletions tests/pos-macros/i15413b/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//> using options -experimental -Yno-experimental

def test = bar.foo
2 changes: 2 additions & 0 deletions tests/pos-macros/i19526b/Test.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

package crash.test

case class Stack private[crash] (
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/Xmacro-settings-compileTimeEnv/Test.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xmacro-settings:a,b=1,c.b.a=x.y.z=1,myLogger.level=INFO
//> using options -experimental -Yno-experimental -Xmacro-settings:a,b=1,c.b.a=x.y.z=1,myLogger.level=INFO

import scala.compiletime.*

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/Xmacro-settings-simple/M1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

package x

import scala.quoted.*
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-global-class/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

package mymacro

import scala.annotation.{experimental, MacroAnnotation}
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-global-class/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import mymacro.addClass

@addClass def foo(): Unit =
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-global-object/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-global-object/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@addClass def foo(): Unit =
println("macro generated main")
println("executed in: " + (new Throwable().getStackTrace().head.getClassName))
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-local-class/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-local-class/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@main def Test(): Unit =
@addClass def foo(): Unit =
println("macro generated main")
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-local-object/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-local-object/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@main def Test(): Unit =
@addClass def foo(): Unit =
println("macro generated main")
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-nested-class/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-nested-class/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

class Foo():
@addClass def foo(): Unit =
println("macro generated main")
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-nested-object/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-add-nested-object/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

class Foo():
@addClass def foo(): Unit =
println("macro generated main")
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-annot-order/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-annot-order/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@print("foo")
def foo(): Unit = ()

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-bind/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-bind/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@bind("a")
val foo: String = "foo"

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-changeVal/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.experimental
import scala.quoted.*
import scala.annotation.MacroAnnotation
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-changeVal/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import ChangeVal._

class Bar:
Expand Down
8 changes: 5 additions & 3 deletions tests/run-macros/annot-concrete-class/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
//> using options -experimental -Yno-experimental

import scala.annotation.MacroAnnotation
import scala.quoted.*

class implementAFoo extends MacroAnnotation:

def transform(using Quotes)(tree: quotes.reflect.Definition): List[quotes.reflect.Definition] =
def transform(using Quotes)(tree: quotes.reflect.Definition): List[quotes.reflect.Definition] =
import quotes.reflect.*
tree match
case ClassDef(name, cstr, parents, self, body) =>
case ClassDef(name, cstr, parents, self, body) =>
val owner = tree.symbol
val sym = Symbol.newMethod(tree.symbol, "foo", ByNameType.apply(TypeRepr.of[String]))
val mtd = DefDef.apply(sym, _ => Some(Literal(StringConstant("Hello, I was added by a MacroAnnotation and without being defined in the class."))))
List(ClassDef.copy(tree)(name, cstr, parents, self, mtd :: body))
case _ => report.errorAndAbort(s"@implementAFoo can only be applied to classes that extend AFoo")

end implementAFoo
4 changes: 2 additions & 2 deletions tests/run-macros/annot-concrete-class/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//> using options -experimental -Yno-experimental

trait AFoo:
def foo: String

@implementAFoo
class Foo extends AFoo

@main def Test =
@main def Test =
val foo = new Foo
println(foo.foo)

2 changes: 2 additions & 0 deletions tests/run-macros/annot-export/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable.Map
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-export/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

object Bar:
@returnClassName
def f(): String = ??? // def f(): String = "Bar"
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-gen2/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-gen2/Macro_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-gen2/Test_3.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

class Bar:
@foo def bar(s: String) = s

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-generate/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-generate/Macro_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-generate/Test_3.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

class Bar:
@foo def bar(x: Int) = x + 1

Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-macro-main/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-macro-main/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//> using options -experimental -Yno-experimental

@mainMacro def Test(): Unit = println("macro generated main")
2 changes: 2 additions & 0 deletions tests/run-macros/annot-memo/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-memo/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

class Bar:
@memoize
def fib(n: Int): Int =
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-mod-class-add-def/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-mod-class-add-def/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@addIndirectToString("This is Foo")
class Foo
//> private def string$macro$1: String = "This is Foo"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-mod-class-add-inner-class/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@addInnerClass
class Foo
//> class Show:
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-mod-class-add-lazy-val/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted._
import scala.collection.mutable
Expand Down
2 changes: 2 additions & 0 deletions tests/run-macros/annot-mod-class-add-lazy-val/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -experimental -Yno-experimental

@addMemoToString("This is Foo")
class Foo
//> private lazy val string$macro$1: String = "This is Foo"
Expand Down
Loading

0 comments on commit 929714c

Please sign in to comment.