Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
* @param body List of members of the class. The members must align with the members of `cls`.
*/
// TODO add selfOpt: Option[ValDef]?
@experimental def apply(cls: Symbol, parents: List[Tree /* Term | TypeTree */], body: List[Statement]): ClassDef
// ^ if a use-case shows up, we add this via an overloaded method
def apply(cls: Symbol, parents: List[Tree /* Term | TypeTree */], body: List[Statement]): ClassDef
def copy(original: Tree)(name: String, constr: DefDef, parents: List[Tree /* Term | TypeTree */], selfOpt: Option[ValDef], body: List[Statement]): ClassDef
def unapply(cdef: ClassDef): (String, DefDef, List[Tree /* Term | TypeTree */], Option[ValDef], List[Statement])

Expand All @@ -518,7 +519,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
* @syntax markdown
*/
// TODO add selfOpt: Option[ValDef]?
@experimental def module(module: Symbol, parents: List[Tree /* Term | TypeTree */], body: List[Statement]): (ValDef, ClassDef)
// ^ if a use-case shows up, we can add this via an overloaded method
def module(module: Symbol, parents: List[Tree /* Term | TypeTree */], body: List[Statement]): (ValDef, ClassDef)
}

/** Makes extension methods on `ClassDef` available without any imports */
Expand Down Expand Up @@ -3878,7 +3880,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
* @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be
* direct or indirect children of the reflection context's owner.
*/
@experimental def newClass(owner: Symbol, name: String, parents: List[TypeRepr], decls: Symbol => List[Symbol], selfType: Option[TypeRepr]): Symbol
def newClass(owner: Symbol, name: String, parents: List[TypeRepr], decls: Symbol => List[Symbol], selfType: Option[TypeRepr]): Symbol

/** Generates a new class symbol for a class with a public single term clause constructor.
*
Expand Down Expand Up @@ -3936,7 +3938,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
* @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be
* direct or indirect children of the reflection context's owner.
*/
@experimental def newClass(
def newClass(
owner: Symbol,
name: String,
parents: Symbol => List[TypeRepr],
Expand Down Expand Up @@ -4038,7 +4040,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
*/
// Keep doc aligned with QuotesImpl's validFlags: `clsFlags` with `validClassFlags`, `conFlags` with `validClassConstructorFlags`,
// conParamFlags with `validClassTypeParamFlags` and `validClassTermParamFlags`
@experimental def newClass(
def newClass(
owner: Symbol,
name: String,
parents: Symbol => List[TypeRepr],
Expand Down Expand Up @@ -4110,7 +4112,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
*
* @syntax markdown
*/
@experimental def newModule(owner: Symbol, name: String, modFlags: Flags, clsFlags: Flags, parents: Symbol => List[TypeRepr], decls: Symbol => List[Symbol], privateWithin: Symbol): Symbol
def newModule(owner: Symbol, name: String, modFlags: Flags, clsFlags: Flags, parents: Symbol => List[TypeRepr], decls: Symbol => List[Symbol], privateWithin: Symbol): Symbol

/** Generates a new method symbol with the given parent, name and type.
*
Expand Down Expand Up @@ -4225,7 +4227,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
*
* @param prefix Prefix of the fresh name
*/
@experimental
def freshName(prefix: String): String
}

Expand Down
5 changes: 4 additions & 1 deletion project/MiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object MiMaFilters {

ProblemFilters.exclude[DirectMissingMethodProblem]("scala.Conversion.underlying"),
ProblemFilters.exclude[MissingClassProblem]("scala.Conversion$"),
ProblemFilters.exclude[MissingClassProblem]("scala.annotation.internal.RuntimeChecked"),
ProblemFilters.exclude[MissingClassProblem]("scala.annotation.internal.RuntimeChecked"),
ProblemFilters.exclude[MissingClassProblem]("scala.annotation.stableNull"),

ProblemFilters.exclude[DirectMissingMethodProblem]("scala.NamedTuple.namedTupleOrdering"),
Expand Down Expand Up @@ -138,6 +138,9 @@ object MiMaFilters {
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#MethodTypeMethods.isContextual"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#ImplicitsModule.searchIgnoring"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#ValDefModule.let"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolModule.newClass"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolModule.newModule"),

// Change `experimental` annotation to a final class
ProblemFilters.exclude[FinalClassProblem]("scala.annotation.experimental"),
),
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i19842-a.check
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
| at dotty.tools.dotc.transform.TreeChecker$.checkParents(TreeChecker.scala:210)
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:286)
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:285)
| at Macros$.makeSerializer(Macro.scala:25)
| at Macros$.makeSerializer(Macro.scala:23)
|
|---------------------------------------------------------------------------------------------------------------------
|Inline stack trace
Expand Down
2 changes: 0 additions & 2 deletions tests/neg-macros/i19842-a/Macro.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.annotation.{experimental, targetName}
import scala.quoted.*
import scala.util.Try
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i19842-b.check
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
| at dotty.tools.dotc.transform.TreeChecker$.checkParents(TreeChecker.scala:210)
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:286)
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:285)
| at Macros$.makeSerializer(Macro.scala:27)
| at Macros$.makeSerializer(Macro.scala:25)
|
|---------------------------------------------------------------------------------------------------------------------
|Inline stack trace
Expand Down
2 changes: 0 additions & 2 deletions tests/neg-macros/i19842-b/Macro.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.annotation.{experimental, targetName}
import scala.quoted.*
import scala.util.Try
Expand Down
2 changes: 0 additions & 2 deletions tests/neg-macros/newClassExtendsNoParents/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

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

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

import scala.quoted.*

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

def test: Foo = makeClass("foo") // error
12 changes: 6 additions & 6 deletions tests/neg-macros/newClassParamsMissingArgument.check
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

-- Error: tests/neg-macros/newClassParamsMissingArgument/Test_2.scala:4:2 ----------------------------------------------
4 | makeClass("foo") // error // error
-- Error: tests/neg-macros/newClassParamsMissingArgument/Test_2.scala:2:2 ----------------------------------------------
2 | makeClass("foo") // error // error
| ^^^^^^^^^^^^^^^^
|wrong number of arguments at inlining (while expanding macro) for (idx: Int): foo: (foo#<init> : (idx: Int): foo), expected: 1, found: 0
-- Error: tests/neg-macros/newClassParamsMissingArgument/Test_2.scala:4:11 ---------------------------------------------
4 | makeClass("foo") // error // error
-- Error: tests/neg-macros/newClassParamsMissingArgument/Test_2.scala:2:11 ---------------------------------------------
2 | makeClass("foo") // error // error
| ^^^^^^^^^^^^^^^^
|Malformed tree was found while expanding macro with -Xcheck-macros.
|The tree does not conform to the compiler's tree invariants.
Expand All @@ -26,7 +26,7 @@
|---------------------------------------------------------------------------------------------------------------------
|Inline stack trace
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from Macro_1.scala:5
5 |inline def makeClass(inline name: String): Object = ${ makeClassExpr('name) }
|This location contains code that was inlined from Macro_1.scala:3
3 |inline def makeClass(inline name: String): Object = ${ makeClassExpr('name) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
---------------------------------------------------------------------------------------------------------------------
2 changes: 0 additions & 2 deletions tests/neg-macros/newClassParamsMissingArgument/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted._

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

@main def Test: Unit = {
makeClass("foo") // error // error
}
2 changes: 0 additions & 2 deletions tests/run-macros/newClass/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

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

@main def Test: Unit = {
val foo = makeClass("foo")
println(foo.getClass)
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassAnnotation/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*
import scala.annotation.StaticAnnotation

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

@main def Test =
val (cls, str) = makeClass("name")
println(str)
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassExtends/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

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

@main def Test: Unit = {
val foo: Foo = makeClass("foo")
foo.foo()
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassExtendsClassParams/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

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

@main def Test: Unit = {
val foo: Foo = makeClass("foo")
foo.foo()
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassExtendsJavaClass/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

transparent inline def makeClass(inline name: String): JavaClass[Int] = ${ makeClassExpr('name) }
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassExtendsJavaClass/Main_2.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

@main def Test: Unit = {
val cls = makeClass("foo")
println(cls.getClass)
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassParams/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted._

inline def makeClassAndCall(inline name: String, idx: Int, str: String): Unit = ${ makeClassAndCallExpr('name, 'idx, 'str) }
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassParams/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

@main def Test: Unit = {
makeClassAndCall("bar", 10, "test")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted._

inline def makeClass(inline name: String): Foo = ${ makeClassExpr('name) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

@main def Test: Unit = {
val foo: Foo = makeClass("foo")
foo.foo()
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassSelf/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

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

@main def Test: Unit = {
val a: Bar = makeClass("A")
a.bar()
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassTraitAndAbstract/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

transparent inline def makeTrait(inline name: String): Any = ${ makeTraitExpr('name) }
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassTraitAndAbstract/Test_2.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

@main def Test: Unit = {
val (cls1, show1) = makeTrait("foo")
println(cls1.getClass)
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassTypeParams/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

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

@main def Test: Unit = {
val (cls, show) = makeClass("foo")
println(cls.getClass)
Expand Down
2 changes: 0 additions & 2 deletions tests/run-macros/newClassTypeParamsDoc/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//> using options -experimental

import scala.quoted.*

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

@main def Test: Unit = {
println(makeClass())
}
10 changes: 2 additions & 8 deletions tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,8 @@ val experimentalDefinitionInLibrary = Set(
//// New APIs: Quotes
// Can be stabilized in 3.5.0 (unsure) or later
"scala.quoted.Quotes.reflectModule.CompilationInfoModule.XmacroSettings",
// Cant be stabilized yet.
// Need newClass variant that can add constructor parameters.
// Need experimental annotation macros to check that design works.
"scala.quoted.Quotes.reflectModule.ClassDefModule.apply",
"scala.quoted.Quotes.reflectModule.ClassDefModule.module",
"scala.quoted.Quotes.reflectModule.SymbolModule.newClass",
"scala.quoted.Quotes.reflectModule.SymbolModule.newModule",
"scala.quoted.Quotes.reflectModule.SymbolModule.freshName",
// Would need an asSeenFrom and ClassInfo added, which we generally do not want
// We need to think if this is necessary, and if so, think of an replacement
"scala.quoted.Quotes.reflectModule.SymbolMethods.info",
// Added for 3.6.0, stabilize after feedback.
"scala.quoted.Quotes.reflectModule.SymbolModule.newBoundedType",
Expand Down
Loading