Skip to content

Commit 88fece2

Browse files
committed
apply review suggestions
1 parent 2e3fbc7 commit 88fece2

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Driver {
4141
report.error(ex.getMessage.nn) // signals that we should fail compilation.
4242
case ex: Throwable if ctx.usedBestEffortTasty =>
4343
report.bestEffortError(ex, "Some best-effort tasty files were not able to be read.")
44+
throw ex
4445
case ex: TypeError if !runOrNull.enrichedErrorMessage =>
4546
println(runOrNull.enrichErrorMessage(s"${ex.toMessage} while compiling ${files.map(_.path).mkString(", ")}"))
4647
throw ex

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,12 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
919919
else cpy.PackageDef(tree)(pid, slicedStats) :: Nil
920920
case tdef: TypeDef =>
921921
val sym = tdef.symbol
922-
if !ctx.isBestEffort then assert(sym.isClass)
922+
assert(sym.isClass || ctx.tolerateErrorsForBestEffort)
923923
if (cls == sym || cls == sym.linkedClass) tdef :: Nil
924924
else Nil
925925
case vdef: ValDef =>
926926
val sym = vdef.symbol
927-
if !ctx.isBestEffort then assert(sym.is(Module))
927+
assert(sym.is(Module) || ctx.tolerateErrorsForBestEffort)
928928
if (cls == sym.companionClass || cls == sym.moduleClass) vdef :: Nil
929929
else Nil
930930
case tree =>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader {
435435
val (classRoot, moduleRoot) = rootDenots(root.asClass)
436436
if (!isBestEffortTasty || ctx.withBestEffortTasty) then
437437
val tastyBytes = tastyFile.toByteArray
438-
val unpickler = new tasty.DottyUnpickler(tastyFile, tastyBytes, isBestEffortTasty = isBestEffortTasty)
439438
unpickler.enter(roots = Set(classRoot, moduleRoot, moduleRoot.sourceModule))(using ctx.withSource(util.NoSource))
440439
if mayLoadTreesFromTasty || isBestEffortTasty then
441440
classRoot.classSymbol.rootTreeOrProvider = unpickler
@@ -446,7 +445,7 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader {
446445
else
447446
checkTastyUUID()
448447
else
449-
report.error(em"Best Effort TASTy $tastyFile file could not be read.")
448+
report.error(em"Cannot read Best Effort TASTy $tastyFile without the ${ctx.settings.YwithBestEffortTasty.name} option")
450449

451450
private def handleUnpicklingExceptions[T](thunk: =>T): T =
452451
try thunk

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
7373
* For regular non best-effort compilation (without best-effort and without using .betasty on classpath),
7474
* this will always return true.
7575
*/
76-
private inline def passesConditionForErroringBestEffortCode(condition: Boolean)(using Context): Boolean =
76+
private inline def passesConditionForErroringBestEffortCode(condition: => Boolean)(using Context): Boolean =
7777
((!ctx.isBestEffort && ctx.reporter.errorsReported) || ctx.usedBestEffortTasty) || condition
7878

7979
def addrOfSym(sym: Symbol): Option[Addr] =

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class TreeUnpickler(reader: TastyReader,
455455
result
456456
}
457457

458-
def readSimpleType(): Type = tag match {
458+
def readSimpleType(): Type = (tag: @switch) match {
459459
case TYPEREFdirect | TERMREFdirect =>
460460
NamedType(NoPrefix, readSymRef())
461461
case TYPEREFsymbol | TERMREFsymbol =>
@@ -497,8 +497,9 @@ class TreeUnpickler(reader: TastyReader,
497497
typeAtAddr.getOrElseUpdate(ref, forkAt(ref).readType())
498498
case BYNAMEtype =>
499499
ExprType(readType())
500-
case ERRORtype if isBestEffortTasty =>
501-
new PreviousErrorType
500+
case ERRORtype =>
501+
if isBestEffortTasty then new PreviousErrorType
502+
else throw new Error(s"Illegal ERRORtype in non Best Effort TASTy file")
502503
case _ =>
503504
ConstantType(readConstant(tag))
504505
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ i14834.scala
1212
# other type related crashes
1313
i4653.scala
1414
overrideClass.scala
15+
16+
# repeating <error> on a top level type definition
17+
# i18750.scala

0 commit comments

Comments
 (0)