Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -5,6 +5,5 @@ package scala.annotation
* @see [[https://dotty.epfl.ch/docs/reference/other-new-features/experimental-defs]]
* @syntax markdown
*/
@deprecatedInheritance("Scheduled for being final in the future", "3.4.0")
class experimental(message: String) extends StaticAnnotation:
final class experimental(message: String) extends StaticAnnotation:
def this() = this("")
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package scala.annotation

@deprecatedInheritance("Scheduled for being final in the future", "3.4.0")
class experimental extends StaticAnnotation
final class experimental extends StaticAnnotation
4 changes: 4 additions & 0 deletions library/src/scala/runtime/stdLibPatches/Predef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ object Predef:
* `eq` or `ne` methods, only `==` and `!=` inherited from `Any`. */
inline def ne(inline y: AnyRef | Null): Boolean =
!(x eq y)

extension (inline opt: Option.type)
@experimental
inline def fromNullable[T](t: T | Null): Option[T] = Option(t).asInstanceOf
end Predef
3 changes: 3 additions & 0 deletions project/MiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object MiMaFilters {
// Additions that require a new minor version of the library
Build.mimaPreviousDottyVersion -> Seq(
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.annotation.experimental.this"),
ProblemFilters.exclude[FinalClassProblem]("scala.annotation.experimental"),
),

// Additions since last LTS
Expand Down Expand Up @@ -56,6 +57,8 @@ object MiMaFilters {
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#MethodTypeModule.apply"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#MethodTypeMethods.methodTypeKind"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#MethodTypeMethods.isContextual"),
// Change `experimental` annotation to a final class
ProblemFilters.exclude[FinalClassProblem]("scala.annotation.experimental"),
),

// Breaking changes since last LTS
Expand Down
6 changes: 6 additions & 0 deletions tests/explicit-nulls/neg/from-nullable.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import scala.annotation.experimental

@experimental def testFromNullable =
val s: String | Null = "abc"
val sopt1: Option[String] = Option(s) // error
val sopt2: Option[String] = Option.fromNullable(s) // ok
1 change: 1 addition & 0 deletions tests/neg/experimentalExperimental.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class MyExperimentalAnnot extends scala.annotation.experimental // error
1 change: 0 additions & 1 deletion tests/pos/experimentalExperimental.scala

This file was deleted.

3 changes: 3 additions & 0 deletions tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ val experimentalDefinitionInLibrary = Set(
"scala.Tuple$.Reverse", // can be stabilized in 3.5
"scala.Tuple$.ReverseOnto", // can be stabilized in 3.5
"scala.runtime.Tuples$.reverse", // can be stabilized in 3.5

// New feature: fromNullable for explicit nulls
"scala.Predef$.fromNullable",
)


Expand Down