@@ -19,7 +19,7 @@ import scala.annotation.internal.sharable
19
19
import scala .util .control .NoStackTrace
20
20
import transform .MacroAnnotations
21
21
22
- class CompilationUnit protected (val source : SourceFile ) {
22
+ class CompilationUnit protected (val source : SourceFile , val info : CompilationUnitInfo | Null ) {
23
23
24
24
override def toString : String = source.toString
25
25
@@ -106,7 +106,7 @@ class CompilationUnit protected (val source: SourceFile) {
106
106
myAssignmentSpans.nn
107
107
}
108
108
109
- @ sharable object NoCompilationUnit extends CompilationUnit (NoSource ) {
109
+ @ sharable object NoCompilationUnit extends CompilationUnit (NoSource , info = null ) {
110
110
111
111
override def isJava : Boolean = false
112
112
@@ -122,13 +122,14 @@ object CompilationUnit {
122
122
123
123
/** Make a compilation unit for top class `clsd` with the contents of the `unpickled` tree */
124
124
def apply (clsd : ClassDenotation , unpickled : Tree , forceTrees : Boolean )(using Context ): CompilationUnit =
125
- val file = clsd.symbol.associatedFile.nn
126
- apply(SourceFile (file, Array .empty[Char ]), unpickled, forceTrees)
125
+ val compilationUnitInfo = clsd.symbol.compilationUnitInfo.nn
126
+ val file = compilationUnitInfo.associatedFile
127
+ apply(SourceFile (file, Array .empty[Char ]), unpickled, forceTrees, compilationUnitInfo)
127
128
128
129
/** Make a compilation unit, given picked bytes and unpickled tree */
129
- def apply (source : SourceFile , unpickled : Tree , forceTrees : Boolean )(using Context ): CompilationUnit = {
130
+ def apply (source : SourceFile , unpickled : Tree , forceTrees : Boolean , info : CompilationUnitInfo )(using Context ): CompilationUnit = {
130
131
assert(! unpickled.isEmpty, unpickled)
131
- val unit1 = new CompilationUnit (source)
132
+ val unit1 = new CompilationUnit (source, info )
132
133
unit1.tpdTree = unpickled
133
134
if (forceTrees) {
134
135
val force = new Force
@@ -156,7 +157,8 @@ object CompilationUnit {
156
157
NoSource
157
158
}
158
159
else source
159
- new CompilationUnit (src)
160
+ val info = if src.exists then CompilationUnitInfo (src.file) else null
161
+ new CompilationUnit (src, info)
160
162
}
161
163
162
164
/** Force the tree to be loaded */
0 commit comments