Skip to content

Commit e678b93

Browse files
committed
Add superTrait annotation
This can be added in a backwards compatible way to cross-compiling sources
1 parent cb063cc commit e678b93

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ class Definitions {
803803
@tu lazy val ScalaStrictFPAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.strictfp")
804804
@tu lazy val ScalaStaticAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.static")
805805
@tu lazy val SerialVersionUIDAnnot: ClassSymbol = ctx.requiredClass("scala.SerialVersionUID")
806+
@tu lazy val SuperTraitAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.superTrait")
806807
@tu lazy val TASTYSignatureAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.internal.TASTYSignature")
807808
@tu lazy val TASTYLongSignatureAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.internal.TASTYLongSignature")
808809
@tu lazy val TailrecAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.tailrec")

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,9 @@ object SymDenotations {
11681168

11691169
final def isSuperTrait(using Context): Boolean =
11701170
isClass
1171-
&& (is(SuperTrait) || defn.assumedSuperTraits.contains(symbol.asClass))
1171+
&& (is(SuperTrait)
1172+
|| defn.assumedSuperTraits.contains(symbol.asClass)
1173+
|| hasAnnotation(defn.SuperTraitAnnot))
11721174

11731175
/** The class containing this denotation which has the given effective name. */
11741176
final def enclosingClassNamed(name: Name)(implicit ctx: Context): Symbol = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package scala.annotation
2+
3+
/** Equivalent to declaring a super trait in Scala 3. This annotation
4+
* should be used only for files that need to cross-compile between
5+
* Scala 2 and 3.
6+
*/
7+
final class superTrait extends StaticAnnotation
8+

0 commit comments

Comments
 (0)