Skip to content

Commit f9a1c15

Browse files
Florian3kjchyb
authored andcommitted
fixes after rebase
1 parent 4c534f4 commit f9a1c15

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,18 +418,16 @@ class ClassfileLoader(val classfile: AbstractFile) extends SymbolLoader {
418418
}
419419

420420
class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader {
421-
421+
val isBestEffortTasty = tastyFile.extension == "betasty"
422422
private val unpickler: tasty.DottyUnpickler =
423423
handleUnpicklingExceptions:
424424
val tastyBytes = tastyFile.toByteArray
425-
new tasty.DottyUnpickler(tastyFile, tastyBytes) // reads header and name table
425+
new tasty.DottyUnpickler(tastyFile, tastyBytes, isBestEffortTasty) // reads header and name table
426426

427427
val compilationUnitInfo: CompilationUnitInfo | Null = unpickler.compilationUnitInfo
428428

429-
val isBestEffortTasty = tastyFile.name.endsWith(".betasty")
430-
431429
def description(using Context): String =
432-
if tastyFile.extension == ".betasty" then "Best Effort TASTy file " + tastyFile.toString
430+
if isBestEffortTasty then "Best Effort TASTy file " + tastyFile.toString
433431
else "TASTy file " + tastyFile.toString
434432

435433
override def doComplete(root: SymDenotation)(using Context): Unit =

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package dotty.tools.dotc
22
package core
33
package tasty
44

5+
import java.util.UUID
56
import scala.language.unsafeNulls
67

78
import dotty.tools.tasty.{TastyFormat, TastyVersion, TastyBuffer, TastyReader, TastyHeaderUnpickler, UnpicklerConfig}
8-
import dotty.tools.tasty.besteffort.BestEffortTastyHeaderUnpickler
9+
import dotty.tools.tasty.besteffort.{BestEffortTastyHeader, BestEffortTastyHeaderUnpickler}
910

1011
import TastyFormat.NameTags.*, TastyFormat.nameTagToString
1112
import TastyBuffer.NameRef
@@ -16,6 +17,18 @@ import NameKinds.*
1617
import dotty.tools.tasty.TastyHeader
1718
import dotty.tools.tasty.TastyBuffer.Addr
1819

20+
case class CommonTastyHeader(
21+
uuid: UUID,
22+
majorVersion: Int,
23+
minorVersion: Int,
24+
experimentalVersion: Int,
25+
toolingVersion: String
26+
):
27+
def this(h: TastyHeader) =
28+
this(h.uuid, h.majorVersion, h.minorVersion, h.experimentalVersion, h.toolingVersion)
29+
def this(h: BestEffortTastyHeader) =
30+
this(h.uuid, h.majorVersion, h.minorVersion, h.experimentalVersion, h.toolingVersion)
31+
1932
object TastyUnpickler {
2033

2134
abstract class SectionUnpickler[R](val name: String) {
@@ -126,9 +139,11 @@ class TastyUnpickler(protected val reader: TastyReader, isBestEffortTasty: Boole
126139
result
127140
}
128141

129-
val header =
130-
if isBestEffortTasty then new BestEffortTastyHeaderUnpickler(scala3CompilerConfig, reader).readFullHeader()
131-
else new TastyHeaderUnpickler(reader).readFullHeader()
142+
val header: CommonTastyHeader =
143+
if isBestEffortTasty then
144+
new CommonTastyHeader(new BestEffortTastyHeaderUnpickler(scala3CompilerConfig, reader).readFullHeader())
145+
else
146+
new CommonTastyHeader(new TastyHeaderUnpickler(reader).readFullHeader())
132147

133148
def readNames(): Unit =
134149
until(readEnd()) { nameAtRef.add(readNameContents()) }

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ class TreeUnpickler(reader: TastyReader,
447447
}
448448
case FLEXIBLEtype =>
449449
FlexibleType(readType())
450+
case _ if isBestEffortTasty =>
451+
goto(end)
452+
new PreviousErrorType
450453
}
451454
assert(currentAddr == end, s"$start $currentAddr $end ${astTagToString(tag)}")
452455
result

compiler/test/dotc/neg-best-effort-pickling.blacklist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ i6796.scala
1010
i14013.scala
1111
toplevel-cyclic
1212
curried-dependent-ift.scala
13+
i17121.scala
14+
illegal-match-types.scala
15+
i13780-1.scala
1316

1417
# semantic db generation fails in the first compilation
1518
i1642.scala

0 commit comments

Comments
 (0)