Skip to content

Stabilize 3.2 APIs #15197

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

Merged
merged 3 commits into from
May 19, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CoverageTests:
def runOnFile(p: Path): Boolean =
scalaFile.matches(p) &&
(Properties.testsFilter.isEmpty || Properties.testsFilter.exists(p.toString.contains))

Files.walk(dir).filter(runOnFile).forEach(path => {
val fileName = path.getFileName.toString.stripSuffix(".scala")
val targetDir = computeCoverageInTmp(path, dir, run)
Expand Down
8 changes: 1 addition & 7 deletions library/src/scala/Tuple.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala

import annotation.{experimental, showAsInfix}
import annotation.showAsInfix
import compiletime._
import compiletime.ops.int._

Expand All @@ -22,7 +22,6 @@ sealed trait Tuple extends Product {
runtime.Tuples.toIArray(this)

/** Return a copy of `this` tuple with an element appended */
@experimental
inline def :* [This >: this.type <: Tuple, L] (x: L): Append[This, L] =
runtime.Tuples.append(x, this).asInstanceOf[Append[This, L]]

Expand Down Expand Up @@ -84,7 +83,6 @@ sealed trait Tuple extends Product {
object Tuple {

/** Type of a tuple with an element appended */
@experimental
type Append[X <: Tuple, Y] <: Tuple = X match {
case EmptyTuple => Y *: EmptyTuple
case x *: xs => x *: Append[xs, Y]
Expand All @@ -96,7 +94,6 @@ object Tuple {
}

/** Type of the initial part of the tuple without its last element */
@experimental
type Init[X <: Tuple] <: Tuple = X match {
case _ *: EmptyTuple => EmptyTuple
case x *: xs =>
Expand All @@ -109,7 +106,6 @@ object Tuple {
}

/** Type of the last element of a tuple */
@experimental
type Last[X <: Tuple] = X match {
case x *: EmptyTuple => x
case _ *: xs => Last[xs]
Expand Down Expand Up @@ -289,12 +285,10 @@ sealed trait NonEmptyTuple extends Tuple {
runtime.Tuples.apply(this, 0).asInstanceOf[Head[This]]

/** Get the initial part of the tuple without its last element */
@experimental
inline def init[This >: this.type <: NonEmptyTuple]: Init[This] =
runtime.Tuples.init(this).asInstanceOf[Init[This]]

/** Get the last of this tuple */
@experimental
inline def last[This >: this.type <: NonEmptyTuple]: Last[This] =
runtime.Tuples.last(this).asInstanceOf[Last[This]]

Expand Down
1 change: 0 additions & 1 deletion library/src/scala/deriving/Mirror.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ object Mirror {
p.fromProduct(a)

/** Create a new instance of type `T` with elements taken from tuple `t`. */
@annotation.experimental
def fromTuple(t: p.MirroredElemTypes): T =
p.fromProduct(t)
}
12 changes: 4 additions & 8 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
*
* @param sym The type symbol for which we are creating a type tree reference.
*/
@experimental
def ref(typeSymbol: Symbol): TypeTree
}

Expand Down Expand Up @@ -2644,11 +2643,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** Substitute all types that refer in their symbol attribute to
* one of the symbols in `from` by the corresponding types in `to`.
*/
@experimental
def substituteTypes(from: List[Symbol], to: List[TypeRepr]): TypeRepr

/** The applied type arguments (empty if there is no such arguments) */
@experimental
def typeArgs: List[TypeRepr]
end extension
}
Expand Down Expand Up @@ -2800,7 +2797,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** Methods of the module object `val AppliedType` */
trait AppliedTypeModule { this: AppliedType.type =>
/** Applied the type constructor `T` to a list of type arguments `T_1,..,T_n` to create `T[T_1,..,T_n]` */
@experimental
def apply(tycon: TypeRepr, args: List[TypeRepr]): AppliedType
def unapply(x: AppliedType): (TypeRepr, List[TypeRepr])
}
Expand Down Expand Up @@ -3947,7 +3943,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
* '{ val x = ???; x }.asTerm
* ```
*/
@experimental
def asQuotes: Nested

/** Type reference to the symbol usable in the scope of its owner.
Expand All @@ -3957,11 +3952,12 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
*
* @pre symbol.isType returns true
*/
@experimental
def typeRef: TypeRef

/** Term reference to the symbol usable in the scope of its owner. */
@experimental
/** Term reference to the symbol usable in the scope of its owner.
*
* @pre symbol.isType returns false
*/
def termRef: TermRef
end extension
}
Expand Down
5 changes: 0 additions & 5 deletions library/src/scala/runtime/Tuples.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package scala.runtime

import scala.annotation.experimental

object Tuples {

inline val MaxSpecialized = 22
Expand Down Expand Up @@ -427,7 +425,6 @@ object Tuples {
}
}

@experimental
def append(x: Any, self: Tuple): Tuple = (self: Any) match {
case xxl: TupleXXL => xxlAppend(x, xxl).asInstanceOf[Tuple]
case _ => specialCaseAppend(x, self)
Expand Down Expand Up @@ -500,13 +497,11 @@ object Tuples {
}
}

@experimental
def init(self: NonEmptyTuple): Tuple = (self: Any) match {
case xxl: TupleXXL => xxlInit(xxl)
case _ => specialCaseInit(self)
}

@experimental
def last(self: NonEmptyTuple): Any = (self: Any) match {
case self: Product => self.productElement(self.productArity - 1)
}
Expand Down
4 changes: 0 additions & 4 deletions library/src/scala/runtime/stdLibPatches/Predef.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package scala.runtime.stdLibPatches

import scala.annotation.experimental

object Predef:
import compiletime.summonFrom

Expand Down Expand Up @@ -54,13 +52,11 @@ object Predef:
/** Enables an expression of type `T|Null`, where `T` is a subtype of `AnyRef`, to be checked for `null`
* using `eq` rather than only `==`. This is needed because `Null` no longer has
* `eq` or `ne` methods, only `==` and `!=` inherited from `Any`. */
@experimental
inline def eq(inline y: AnyRef | Null): Boolean =
x.asInstanceOf[AnyRef] eq y.asInstanceOf[AnyRef]
/** Enables an expression of type `T|Null`, where `T` is a subtype of `AnyRef`, to be checked for `null`
* using `ne` rather than only `!=`. This is needed because `Null` no longer has
* `eq` or `ne` methods, only `==` and `!=` inherited from `Any`. */
@experimental
inline def ne(inline y: AnyRef | Null): Boolean =
!(x eq y)

Expand Down
7 changes: 7 additions & 0 deletions project/MiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ object MiMaFilters {
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.quoted.runtime.QuoteUnpickler.unpickleTypeV2"),

ProblemFilters.exclude[MissingClassProblem]("scala.annotation.since"),

// APIs will be added in 3.2.0
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#AppliedTypeModule.apply"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.asQuotes"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.typeRef"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.termRef"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TypeTreeModule.ref"),
)
}
5 changes: 4 additions & 1 deletion tests/coverage/pos/Inlined.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package covtest
// Checks that we use the new positions of the inlined code properly
def testInlined(): Unit =
val l = 1
assert(l == 1) // scala.Predef.assert is inline in dotty
assert(l == 1)
assert(l == List(l).length)
assert(List(l).length == 1)

transparent inline def assert(inline assertion: Boolean): Unit =
if !assertion then scala.runtime.Scala3RunTime.assertFailed()
Loading