Skip to content

Commit 1cc636d

Browse files
committed
Stabilise Quotes reflect methods used for creating new classes/objects
1 parent a431d3a commit 1cc636d

File tree

36 files changed

+22
-84
lines changed

36 files changed

+22
-84
lines changed

library/src/scala/quoted/Quotes.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
493493
* @param body List of members of the class. The members must align with the members of `cls`.
494494
*/
495495
// TODO add selfOpt: Option[ValDef]?
496-
@experimental def apply(cls: Symbol, parents: List[Tree /* Term | TypeTree */], body: List[Statement]): ClassDef
496+
// ^ if a use-case shows up, we add this via an overloaded method
497+
def apply(cls: Symbol, parents: List[Tree /* Term | TypeTree */], body: List[Statement]): ClassDef
497498
def copy(original: Tree)(name: String, constr: DefDef, parents: List[Tree /* Term | TypeTree */], selfOpt: Option[ValDef], body: List[Statement]): ClassDef
498499
def unapply(cdef: ClassDef): (String, DefDef, List[Tree /* Term | TypeTree */], Option[ValDef], List[Statement])
499500

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

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

38833885
/** Generates a new class symbol for a class with a public single term clause constructor.
38843886
*
@@ -3936,7 +3938,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
39363938
* @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be
39373939
* direct or indirect children of the reflection context's owner.
39383940
*/
3939-
@experimental def newClass(
3941+
def newClass(
39403942
owner: Symbol,
39413943
name: String,
39423944
parents: Symbol => List[TypeRepr],
@@ -4038,7 +4040,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
40384040
*/
40394041
// Keep doc aligned with QuotesImpl's validFlags: `clsFlags` with `validClassFlags`, `conFlags` with `validClassConstructorFlags`,
40404042
// conParamFlags with `validClassTypeParamFlags` and `validClassTermParamFlags`
4041-
@experimental def newClass(
4043+
def newClass(
40424044
owner: Symbol,
40434045
name: String,
40444046
parents: Symbol => List[TypeRepr],
@@ -4110,7 +4112,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
41104112
*
41114113
* @syntax markdown
41124114
*/
4113-
@experimental def newModule(owner: Symbol, name: String, modFlags: Flags, clsFlags: Flags, parents: Symbol => List[TypeRepr], decls: Symbol => List[Symbol], privateWithin: Symbol): Symbol
4115+
def newModule(owner: Symbol, name: String, modFlags: Flags, clsFlags: Flags, parents: Symbol => List[TypeRepr], decls: Symbol => List[Symbol], privateWithin: Symbol): Symbol
41144116

41154117
/** Generates a new method symbol with the given parent, name and type.
41164118
*
@@ -4225,7 +4227,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
42254227
*
42264228
* @param prefix Prefix of the fresh name
42274229
*/
4228-
@experimental
42294230
def freshName(prefix: String): String
42304231
}
42314232

project/MiMaFilters.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object MiMaFilters {
1717

1818
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.Conversion.underlying"),
1919
ProblemFilters.exclude[MissingClassProblem]("scala.Conversion$"),
20-
ProblemFilters.exclude[MissingClassProblem]("scala.annotation.internal.RuntimeChecked"),
20+
ProblemFilters.exclude[MissingClassProblem]("scala.annotation.internal.RuntimeChecked"),
2121
ProblemFilters.exclude[MissingClassProblem]("scala.annotation.stableNull"),
2222

2323
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.NamedTuple.namedTupleOrdering"),
@@ -138,6 +138,9 @@ object MiMaFilters {
138138
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#MethodTypeMethods.isContextual"),
139139
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#ImplicitsModule.searchIgnoring"),
140140
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#ValDefModule.let"),
141+
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolModule.newClass"),
142+
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolModule.newModule"),
143+
141144
// Change `experimental` annotation to a final class
142145
ProblemFilters.exclude[FinalClassProblem]("scala.annotation.experimental"),
143146
),

tests/neg-macros/i19842-a.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| at dotty.tools.dotc.transform.TreeChecker$.checkParents(TreeChecker.scala:210)
1212
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:286)
1313
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:285)
14-
| at Macros$.makeSerializer(Macro.scala:25)
14+
| at Macros$.makeSerializer(Macro.scala:23)
1515
|
1616
|---------------------------------------------------------------------------------------------------------------------
1717
|Inline stack trace

tests/neg-macros/i19842-a/Macro.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -experimental
2-
31
import scala.annotation.{experimental, targetName}
42
import scala.quoted.*
53
import scala.util.Try

tests/neg-macros/i19842-b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| at dotty.tools.dotc.transform.TreeChecker$.checkParents(TreeChecker.scala:210)
1212
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:286)
1313
| at scala.quoted.runtime.impl.QuotesImpl$reflect$ClassDef$.module(QuotesImpl.scala:285)
14-
| at Macros$.makeSerializer(Macro.scala:27)
14+
| at Macros$.makeSerializer(Macro.scala:25)
1515
|
1616
|---------------------------------------------------------------------------------------------------------------------
1717
|Inline stack trace

tests/neg-macros/i19842-b/Macro.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -experimental
2-
31
import scala.annotation.{experimental, targetName}
42
import scala.quoted.*
53
import scala.util.Try

tests/neg-macros/newClassExtendsNoParents/Macro_1.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -experimental
2-
31
import scala.quoted.*
42

53
inline def makeClass(inline name: String): Any = ${ makeClassExpr('name) }
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
//> using options -experimental
2-
31
def test: Any = makeClass("foo") // error

tests/neg-macros/newClassExtendsOnlyTrait/Macro_1.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -experimental
2-
31
import scala.quoted.*
42

53
inline def makeClass(inline name: String): Foo = ${ makeClassExpr('name) }
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
//> using options -experimental
2-
31
def test: Foo = makeClass("foo") // error

0 commit comments

Comments
 (0)