@@ -5,6 +5,7 @@ package core
5
5
import scala .annotation .{threadUnsafe => tu }
6
6
import Types ._ , Contexts ._ , Symbols ._ , SymDenotations ._ , StdNames ._ , Names ._ , Phases ._
7
7
import Flags ._ , Scopes ._ , Decorators ._ , NameOps ._ , Periods ._ , NullOpsDecorator ._
8
+ import ast .tpd .Literal , Constants .Constant
8
9
import unpickleScala2 .Scala2Unpickler .ensureConstructor
9
10
import scala .collection .mutable
10
11
import collection .mutable
@@ -14,6 +15,7 @@ import typer.ImportInfo.RootRef
14
15
import Comments .CommentsContext
15
16
import Comments .Comment
16
17
import util .Spans .NoSpan
18
+ import Annotations .Annotation
17
19
18
20
import scala .annotation .tailrec
19
21
@@ -1111,6 +1113,9 @@ class Definitions {
1111
1113
* is read from a classfile.
1112
1114
*/
1113
1115
def patchStdLibClass (denot : ClassDenotation )(using Context ): Unit =
1116
+ val annot = Annotation .deferredSymAndTree(defn.CompileTimeOnlyAnnot ) {
1117
+ Literal (Constant (" The symbol can only be used at compile time in import statements" ))
1118
+ }
1114
1119
1115
1120
def patch2 (denot : ClassDenotation , patchCls : Symbol ): Unit =
1116
1121
val scope = denot.info.decls.openForMutations
@@ -1124,9 +1129,11 @@ class Definitions {
1124
1129
for patch <- patches do
1125
1130
patch.ensureCompleted()
1126
1131
if ! recurse(patch) then
1127
- patch.denot = patch.denot.copySymDenotation(owner = denot.symbol)
1128
- scope.enter(patch)
1129
- else if patch.isClass then
1132
+ val copy = patch.copy(owner = denot.symbol)
1133
+ copy.denot = patch.denot.copySymDenotation(owner = denot.symbol)
1134
+ copy.addAnnotation(annot)
1135
+ scope.enter(copy)
1136
+ if patch.isClass then
1130
1137
patch2(scope.lookup(patch.name).asClass, patch)
1131
1138
1132
1139
def patchWith (patchCls : Symbol ) =
0 commit comments