Skip to content

Commit 3342b6b

Browse files
committed
chore: deprecate scala.annotation.transparentTrait
1 parent 9bee756 commit 3342b6b

File tree

6 files changed

+5
-7
lines changed

6 files changed

+5
-7
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

-1
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,6 @@ class Definitions {
10481048
@tu lazy val NowarnAnnot: ClassSymbol = requiredClass("scala.annotation.nowarn")
10491049
@tu lazy val UnusedAnnot: ClassSymbol = requiredClass("scala.annotation.unused")
10501050
@tu lazy val UnrollAnnot: ClassSymbol = requiredClass("scala.annotation.unroll")
1051-
@tu lazy val TransparentTraitAnnot: ClassSymbol = requiredClass("scala.annotation.transparentTrait")
10521051
@tu lazy val NativeAnnot: ClassSymbol = requiredClass("scala.native")
10531052
@tu lazy val RepeatedAnnot: ClassSymbol = requiredClass("scala.annotation.internal.Repeated")
10541053
@tu lazy val RuntimeCheckedAnnot: ClassSymbol = requiredClass("scala.annotation.internal.RuntimeChecked")

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -1220,9 +1220,7 @@ object SymDenotations {
12201220
|| accessBoundary(defn.RootClass).isProperlyContainedIn(symbol.topLevelClass)
12211221

12221222
final def isTransparentClass(using Context): Boolean =
1223-
is(TransparentType)
1224-
|| defn.isAssumedTransparent(symbol)
1225-
|| isClass && hasAnnotation(defn.TransparentTraitAnnot)
1223+
is(TransparentType) || defn.isAssumedTransparent(symbol)
12261224

12271225
/** The class containing this denotation which has the given effective name. */
12281226
final def enclosingClassNamed(name: Name)(using Context): Symbol = {

docs/_docs/reference/other-new-features/transparent-traits.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ will have type `Int | String` instead of the widened type `Any`.
5959

6060
## Which Traits and Classes Are Transparent?
6161

62-
Traits and classes are declared transparent by adding the modifier `transparent`. Scala 2 traits and classes can also be declared transparent by adding a [`@transparentTrait`](https://scala-lang.org/api/3.x/scala/annotation/transparentTrait.html) annotation. This annotation is defined in [`scala.annotation`](https://scala-lang.org/api/3.x/scala/annotation.html). It will be deprecated and phased out once Scala 2/3 interoperability is no longer needed.
62+
Traits and classes are declared transparent by adding the modifier `transparent`.
6363

6464
The following classes and traits are automatically treated as transparent:
6565
```scala

library/src/scala/annotation/transparentTrait.scala

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ package scala.annotation
55
* are not inferred when combined with other types in an intersection.
66
* See reference/other-new-features/transparent-traits.html for details.
77
*/
8+
@deprecated(message = "Transparent traits/classes via annotations is no longer supported. Use instead the `transparent` modifier", since = "3.8.0")
89
final class transparentTrait extends StaticAnnotation

library/src/scala/reflect/Enum.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package scala.reflect
22

33
/** A base trait of all Scala enum definitions */
4-
@annotation.transparentTrait trait Enum extends Any, Product, Serializable:
4+
transparent trait Enum extends Any, Product, Serializable:
55

66
/** A number uniquely identifying a case of an enum */
77
def ordinal: Int

library/src/scala/runtime/EnumValue.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.runtime
22

3-
@annotation.transparentTrait trait EnumValue extends Product, Serializable:
3+
transparent trait EnumValue extends Product, Serializable:
44
override def canEqual(that: Any) = this eq that.asInstanceOf[AnyRef]
55
override def productArity: Int = 0
66
override def productElement(n: Int): Any =

0 commit comments

Comments
 (0)