Skip to content
Draft
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
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ object Annotations {
/** Operations for hash-consing, can be overridden */
def hash: Int = System.identityHashCode(this)
def eql(that: Annotation) = this eq that

final def isExportable(using Context): Boolean =
symbol.hasAnnotation(defn.ExportableAnnotation)
}

case class ConcreteAnnotation(t: Tree) extends Annotation:
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ class Definitions {
@tu lazy val GetterMetaAnnot: ClassSymbol = requiredClass("scala.annotation.meta.getter")
@tu lazy val ParamMetaAnnot: ClassSymbol = requiredClass("scala.annotation.meta.param")
@tu lazy val SetterMetaAnnot: ClassSymbol = requiredClass("scala.annotation.meta.setter")
@tu lazy val ExportableAnnotation: ClassSymbol = requiredClass("scala.annotation.meta.exportable")
@tu lazy val CompanionClassMetaAnnot: ClassSymbol = requiredClass("scala.annotation.meta.companionClass")
@tu lazy val CompanionMethodMetaAnnot: ClassSymbol = requiredClass("scala.annotation.meta.companionMethod")
@tu lazy val ShowAsInfixAnnot: ClassSymbol = requiredClass("scala.annotation.showAsInfix")
Expand Down
7 changes: 1 addition & 6 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1351,12 +1351,7 @@ class Namer { typer: Typer =>
forwarder.info = avoidPrivateLeaks(forwarder)

// Add annotations at the member level
forwarder.addAnnotations(sym.annotations.filterConserve { annot =>
annot.symbol != defn.BodyAnnot
&& annot.symbol != defn.TailrecAnnot
&& annot.symbol != defn.MainAnnot
&& !annot.symbol.derivesFrom(defn.MacroAnnotationClass)
})
forwarder.addAnnotations(sym.annotations.filterConserve(_.isExportable))

if forwarder.isType then
buf += tpd.TypeDef(forwarder.asType).withSpan(span)
Expand Down
2 changes: 2 additions & 0 deletions library/src/scala/annotation/experimental.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package scala.annotation

import language.experimental.captureChecking
import meta.exportable

/** An annotation that can be used to mark a definition as experimental.
*
* @see [[https://dotty.epfl.ch/docs/reference/other-new-features/experimental-defs]]
* @syntax markdown
*/
@exportable
final class experimental(message: String) extends StaticAnnotation:
def this() = this("")
3 changes: 3 additions & 0 deletions library/src/scala/annotation/meta/exportable.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package scala.annotation.meta

final class exportable extends scala.annotation.StaticAnnotation
2 changes: 2 additions & 0 deletions library/src/scala/annotation/targetName.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package scala.annotation

import language.experimental.captureChecking
import meta.exportable

/** An annotation that defines an external name for a definition.
* If an `targetName(extname)` annotation is given for a method or some other
* definition, its implementation will use the name `extname` instead of
* the regular name.
*/
@exportable
final class targetName(name: String) extends StaticAnnotation
1 change: 1 addition & 0 deletions library/src/scala/deprecated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import scala.annotation.meta._
* @see [[scala.deprecatedOverriding]]
* @see [[scala.deprecatedName]]
*/
@exportable
@getter @setter @beanGetter @beanSetter @field
@deprecatedInheritance("Scheduled for being final in the future", "2.13.0")
class deprecated(message: String = "", since: String = "") extends scala.annotation.ConstantAnnotation
2 changes: 2 additions & 0 deletions library/src/scala/throws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package scala

import scala.language.`2.13`
import scala.annotation.meta.exportable

/**
* Annotation for specifying the exceptions thrown by a method.
Expand All @@ -25,6 +26,7 @@ import scala.language.`2.13`
* }
* }}}
*/
@exportable
final class throws[T <: Throwable](cause: String = "") extends scala.annotation.StaticAnnotation {
def this(clazz: Class[T]) = this("")
}
Loading