Skip to content

Commit a7be5e2

Browse files
committed
Move sharable/unshared annotations to dotty-library
Previously they were in dotty-compiler, which means that running `-Ycheck:reentrant` on a non-bootstrapped compiler would try to load symbols from the non-bootstrapped compiler itself.
1 parent 970bafa commit a7be5e2

32 files changed

+71
-7
lines changed

compiler/src/dotty/tools/dotc/Bench.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package dotc
44
import core.Contexts.Context
55
import reporting.Reporter
66

7+
import scala.annotation.internal.sharable
8+
79
/** A main class for running compiler benchmarks. Can instantiate a given
810
* number of compilers and run each (sequentially) a given number of times
911
* on the same sources.

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import collection.mutable.ListBuffer
1313
import reporting.diagnostic.messages._
1414
import reporting.trace
1515

16+
import scala.annotation.internal.sharable
17+
1618
object desugar {
1719
import untpd._
1820
import DesugarEnums._

compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import collection.mutable.ListBuffer
1010
import util.Property
1111
import typer.ErrorReporting._
1212

13+
import scala.annotation.internal.sharable
14+
1315
/** Helper methods to desugar enums */
1416
object DesugarEnums {
1517
import untpd._

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import parsing.Tokens.Token
1414
import printing.Printer
1515
import util.{Stats, Attachment, Property, DotClass}
1616
import config.Config
17+
import annotation.internal.sharable
1718
import annotation.unchecked.uncheckedVariance
1819
import language.implicitConversions
1920

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import language.higherKinds
1111
import collection.mutable.ListBuffer
1212
import reflect.ClassTag
1313

14+
import scala.annotation.internal.sharable
15+
1416
object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
1517

1618
// ----- Tree cases that exist in untyped form only ------------------

compiler/src/dotty/tools/dotc/config/CommandLineParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools.dotc
22
package config
33

44
import scala.annotation.tailrec
5-
import dotty.tools.sharable
5+
import scala.annotation.internal.sharable
66

77
/** A simple (overly so) command line parser.
88
* !!! This needs a thorough test suite to make sure quoting is

compiler/src/dotty/tools/dotc/config/Properties.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package config
44

5+
import scala.annotation.internal.sharable
6+
57
import java.io.{ IOException, PrintWriter }
68
import java.util.jar.Attributes.{ Name => AttributeName }
79

compiler/src/dotty/tools/dotc/config/ScalaVersion.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package dotty.tools
44
package dotc.config
55

6+
import scala.annotation.internal.sharable
67
import scala.util.{Try, Success, Failure}
78

89
/**

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import collection.immutable.BitSet
2929
import printing._
3030
import config.{JavaPlatform, Platform, ScalaSettings, Settings}
3131

32+
import scala.annotation.internal.sharable
33+
3234
import language.implicitConversions
3335
import DenotTransformers.DenotTransformer
3436
import dotty.tools.dotc.profile.Profiler

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Decorators._
1111
import Contexts.Context
1212
import collection.mutable
1313

14+
import scala.annotation.internal.sharable
15+
1416
/** Defines possible kinds of NameInfo of a derived name */
1517
object NameKinds {
1618

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import util.{DotClass}
1616
import config.Config
1717
import java.util.HashMap
1818

19+
import scala.annotation.internal.sharable
20+
1921
object Names {
2022
import NameKinds._
2123

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import reporting.diagnostic.Message
2424
import reporting.diagnostic.messages.BadSymbolicReference
2525
import reporting.trace
2626

27+
import scala.annotation.internal.sharable
28+
2729
trait SymDenotations { this: Context =>
2830
import SymDenotations._
2931

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import io.AbstractFile
3131
import language.implicitConversions
3232
import util.{NoSource, DotClass, Property}
3333
import scala.collection.JavaConverters._
34+
import scala.annotation.internal.sharable
3435
import config.Printers.typr
3536

3637
/** Creation methods for symbols */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import ast.tpd._
1919
import reporting.trace
2020
import reporting.diagnostic.Message
2121

22+
import scala.annotation.internal.sharable
23+
2224
trait TypeOps { this: Context => // TODO: Make standalone object.
2325

2426
/** The type `tp` as seen from prefix `pre` and owner `cls`. See the spec

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import collection.mutable
1414
import java.lang.ref.WeakReference
1515
import Decorators._
1616

17+
import scala.annotation.internal.sharable
18+
1719
object TyperState {
1820
@sharable private var nextId: Int = 0
1921
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import scala.util.hashing.{ MurmurHash3 => hashing }
3636
import config.Printers.{core, typr}
3737
import java.lang.ref.WeakReference
3838

39+
import scala.annotation.internal.sharable
40+
3941
object Types {
4042

4143
@sharable private[this] var nextId = 0

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import scala.quoted
2525
import scala.quoted.Types.TreeType
2626
import scala.quoted.Exprs.TastyTreeExpr
2727

28+
import scala.annotation.internal.sharable
29+
2830
/** Unpickler for typed trees
2931
* @param reader the reader from which to unpickle
3032
* @param posUnpicklerOpt the unpickler for positions, if it exists

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dotty.tools
22
package dotc
33
package parsing
44

5+
import scala.annotation.internal.sharable
56
import scala.collection.mutable.ListBuffer
67
import scala.collection.immutable.BitSet
78
import util.{ SourceFile, SourcePosition }

compiler/src/dotty/tools/dotc/printing/Printer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import Types.Type, Symbols.Symbol, Contexts.Context, Scopes.Scope, Constants.Con
99
import typer.Implicits.SearchResult
1010
import typer.ImportInfo
1111

12+
import scala.annotation.internal.sharable
13+
1214
/** The base class of all printers
1315
*/
1416
abstract class Printer {

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package reporting
44

5+
import scala.annotation.internal.sharable
6+
57
import core.Contexts._
68
import util.{SourcePosition, NoSourcePosition}
79
import core.Decorators.PhaseListDecorator

compiler/src/dotty/tools/dotc/transform/CheckReentrant.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class CheckReentrant extends MiniPhase {
5050
private[this] var indent: Int = 0
5151

5252
private val sharableAnnot = new CtxLazy(implicit ctx =>
53-
ctx.requiredClass("dotty.tools.sharable"))
53+
ctx.requiredClass("scala.annotation.internal.sharable"))
5454
private val unsharedAnnot = new CtxLazy(implicit ctx =>
55-
ctx.requiredClass("dotty.tools.unshared"))
55+
ctx.requiredClass("scala.annotation.internal.unshared"))
5656

5757
def isIgnored(sym: Symbol)(implicit ctx: Context) =
5858
sym.hasAnnotation(sharableAnnot()) ||
@@ -92,4 +92,4 @@ class CheckReentrant extends MiniPhase {
9292
addVars(tree.symbol.owner.asClass)
9393
tree
9494
}
95-
}
95+
}

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ import config.Printers.{implicits, implicitsDetailed, typr}
3737
import collection.mutable
3838
import reporting.trace
3939

40+
import scala.annotation.internal.sharable
41+
4042
/** Implicit resolution */
4143
object Implicits {
4244
import tpd._

compiler/src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import reporting._
2222
import collection.mutable
2323
import config.Config
2424

25+
import scala.annotation.internal.sharable
26+
2527
object Inferencing {
2628

2729
import tpd._

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import ErrorReporting.errorType
1919
import config.Printers.typr
2020
import collection.mutable
2121

22+
import scala.annotation.internal.sharable
23+
2224
object ProtoTypes {
2325

2426
import tpd._

compiler/src/dotty/tools/dotc/util/NameTransformer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import core.Decorators._
77
import collection.mutable
88
import util.Chars.isValidJVMMethodChar
99

10+
import scala.annotation.internal.sharable
11+
1012
/** Provides functions to encode and decode Scala symbolic names.
1113
*/
1214
object NameTransformer {

compiler/src/dotty/tools/dotc/util/SourceFile.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Chars._
1111
import ScriptSourceFile._
1212
import Positions._
1313
import scala.io.Codec
14+
import scala.annotation.internal.sharable
1415

1516
import java.util.Optional
1617

compiler/src/dotty/tools/dotc/util/SourcePosition.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package util
44

55
import Positions.{Position, NoPosition}
66

7+
import scala.annotation.internal.sharable
8+
79
/** A source position is comprised of a position in a source file */
810
case class SourcePosition(source: SourceFile, pos: Position, outer: SourcePosition = NoSourcePosition)
911
extends interfaces.SourcePosition {

compiler/src/dotty/tools/dotc/util/Stats.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package util
44

5+
import scala.annotation.internal.sharable
6+
57
import core.Contexts._
68
import collection.mutable
79

compiler/src/dotty/tools/package.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ package dotty
22
import scala.annotation.Annotation
33

44
package object tools {
5-
class sharable extends Annotation
6-
class unshared extends Annotation
7-
85
// Ensure this object is already classloaded, since it's only actually used
96
// when handling stack overflows and every operation (including class loading)
107
// risks failing.

compiler/src/dotty/tools/repl/ParseResult.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import dotc.reporting._
1111

1212
import results._
1313

14+
import scala.annotation.internal.sharable
15+
1416
/** A parsing result from string input */
1517
sealed trait ParseResult
1618

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package scala.annotation.internal
2+
3+
import scala.annotation.Annotation
4+
5+
/** An annotation indicating to `-Ycheck:reentrant` that a class or val can be safely shared.
6+
*
7+
* @see scala.annotation.internal.unshared
8+
*/
9+
class sharable extends Annotation
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package scala.annotation.internal
2+
3+
import scala.annotation.Annotation
4+
5+
/** An annotation indicating to `-Ycheck:reentrant` that an object will not be accessed from multiple threads.
6+
*
7+
* @see scala.annotation.internal.sharable
8+
*/
9+
class unshared extends Annotation

0 commit comments

Comments
 (0)