Skip to content

Commit eff9c27

Browse files
committed
Add explicit nulls tasty attribute to CompilationUnit
1 parent a4fc774 commit eff9c27

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import dotty.tools.tasty.TastyVersion
99
* the class containing this symbol was generated,
1010
* null if not applicable.
1111
* @param tastyVersion The TASTy version (major, minor, experimental)
12+
* @param tastyExplicitNulls Was this compilation unit compiled with explicit nulls?
1213
*/
1314
class CompilationUnitInfo(
1415
val associatedFile: AbstractFile,
1516
val tastyVersion: Option[TastyVersion],
17+
val tastyExplicitNulls: Boolean
1618
) {
1719

1820
override def toString(): String =
@@ -22,4 +24,8 @@ class CompilationUnitInfo(
2224
object CompilationUnitInfo:
2325
def apply(assocFile: AbstractFile | Null): CompilationUnitInfo | Null =
2426
if assocFile == null then null
25-
else new CompilationUnitInfo(assocFile, tastyVersion = None) // TODO use current TASTy version
27+
else new CompilationUnitInfo(
28+
assocFile,
29+
tastyVersion = None,
30+
tastyExplicitNulls = false
31+
)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,11 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader {
424424

425425
def compilationUnitInfo: CompilationUnitInfo | Null =
426426
val tastyHeader = unpickler.unpickler.header
427+
val attributes = unpickler.tastyAttributes
427428
new CompilationUnitInfo(
428429
tastyFile,
429430
tastyVersion = Some(tastyHeader.version),
431+
tastyExplicitNulls = attributes.explicitNulls,
430432
)
431433

432434
def description(using Context): String = "TASTy file " + tastyFile.toString

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class DottyUnpickler(bytes: Array[Byte], mode: UnpickleMode = UnpickleMode.TopLe
5656
private val attributeUnpicklerOpt = unpickler.unpickle(new AttributesSectionUnpickler)
5757
private val treeUnpickler = unpickler.unpickle(treeSectionUnpickler(posUnpicklerOpt, commentUnpicklerOpt, attributeUnpicklerOpt)).get
5858

59+
def tastyAttributes: Attributes =
60+
attributeUnpicklerOpt.map(_.attributes).getOrElse(Attributes(false, false))
61+
5962
/** Enter all toplevel classes and objects into their scopes
6063
* @param roots a set of SymDenotations that should be overwritten by unpickling
6164
*/

0 commit comments

Comments
 (0)