Skip to content

Commit

Permalink
Add a @nonHotParameters annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
natsukagami committed Nov 24, 2021
1 parent ca483f8 commit 151735e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
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 @@ -942,6 +942,7 @@ class Definitions {
@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")
@tu lazy val NonHotParamsAnnot: ClassSymbol = requiredClass("scala.annotation.nonHotParameters")

@tu lazy val JavaRepeatableAnnot: ClassSymbol = requiredClass("java.lang.annotation.Repeatable")

Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/SymUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ object SymUtils:

def isVolatile(using Context): Boolean = self.hasAnnotation(defn.VolatileAnnot)

def isNonHotParams(using Context): Boolean = self.hasAnnotation(defn.NonHotParamsAnnot)

def isAnyOverride(using Context): Boolean = self.is(Override) || self.is(AbsOverride)
// careful: AbsOverride is a term only flag. combining with Override would catch only terms.

Expand Down
7 changes: 7 additions & 0 deletions library/src/scala/annotation/nonHotParams.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package scala.annotation

/** An annotation that marks a method as taking non-hot parameters.
* The initialization checker will not require all parameters to be hot at call-site,
* opting to run a more expensive analysis.
*/
final class nonHotParameters extends StaticAnnotation

0 comments on commit 151735e

Please sign in to comment.