diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index eaafcca3992e..ea6652705e60 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -921,7 +921,6 @@ class Definitions { @tu lazy val ParamMetaAnnot: ClassSymbol = requiredClass("scala.annotation.meta.param") @tu lazy val SetterMetaAnnot: ClassSymbol = requiredClass("scala.annotation.meta.setter") @tu lazy val ShowAsInfixAnnot: ClassSymbol = requiredClass("scala.annotation.showAsInfix") - @tu lazy val StableAnnot: ClassSymbol = requiredClass("scala.annotation.internal.Stable") @tu lazy val FunctionalInterfaceAnnot: ClassSymbol = requiredClass("java.lang.FunctionalInterface") @tu lazy val TargetNameAnnot: ClassSymbol = requiredClass("scala.annotation.targetName") @tu lazy val VarargsAnnot: ClassSymbol = requiredClass("scala.annotation.varargs") diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 842bd3b403e2..684b8faa13ea 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -168,7 +168,11 @@ object Types { case _: SingletonType | NoPrefix => true case tp: RefinedOrRecType => tp.parent.isStable case tp: ExprType => tp.resultType.isStable - case tp: AnnotatedType => tp.annot.symbol == defn.StableAnnot || tp.parent.isStable + case tp: AnnotatedType => + // NOTE UncheckedStableAnnot was originally meant to be put on fields, + // not on types. Allowing it on types is a Scala 3 extension. See: + // https://www.scala-lang.org/files/archive/spec/2.11/11-annotations.html#scala-compiler-annotations + tp.annot.symbol == defn.UncheckedStableAnnot || tp.parent.isStable case tp: AndType => // TODO: fix And type check when tp contains type parames for explicit-nulls flow-typing // see: tests/explicit-nulls/pos/flow-stable.scala.disabled diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 0c7867a03bdc..98934734aae3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3539,7 +3539,7 @@ class Typer extends Namer // this is needed for -Ycheck. Without the annotation Ycheck will // skolemize the result type which will lead to different types before // and after checking. See i11955.scala. - AnnotatedType(conj, Annotation(defn.StableAnnot)) + AnnotatedType(conj, Annotation(defn.UncheckedStableAnnot)) else conj else pt gadts.println(i"insert GADT cast from $tree to $target") diff --git a/library/src/scala/annotation/internal/Stable.scala b/library/src/scala/annotation/internal/Stable.scala deleted file mode 100644 index bb53701716b5..000000000000 --- a/library/src/scala/annotation/internal/Stable.scala +++ /dev/null @@ -1,6 +0,0 @@ -package scala.annotation.internal - -import scala.annotation.Annotation - -/** An annotation asserting that the annotated type is stable */ -final class Stable() extends Annotation