Skip to content

Commit ae78649

Browse files
committed
Adjust assertions and errors to be more relaxed under --from-tasty compilation (Mode.ReadPositions)
1 parent 26440da commit ae78649

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,12 +1012,12 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
10121012
else cpy.PackageDef(tree)(pid, slicedStats) :: Nil
10131013
case tdef: TypeDef =>
10141014
val sym = tdef.symbol
1015-
assert(sym.isClass || ctx.tolerateErrorsForBestEffort)
1015+
assert(sym.isClass || ctx.tolerateErrorsForBestEffort || ctx.mode.is(Mode.ReadPositions))
10161016
if (cls == sym || cls == sym.linkedClass) tdef :: Nil
10171017
else Nil
10181018
case vdef: ValDef =>
10191019
val sym = vdef.symbol
1020-
assert(sym.is(Module) || ctx.tolerateErrorsForBestEffort)
1020+
assert(sym.is(Module) || ctx.tolerateErrorsForBestEffort || ctx.mode.is(Mode.ReadPositions))
10211021
if (cls == sym.companionClass || cls == sym.moduleClass) vdef :: Nil
10221022
else Nil
10231023
case tree =>

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ object CheckCaptures:
113113
if refSym.isType && !refSym.info.derivesFrom(defn.Caps_CapSet) then
114114
report.error(em"$elem is not a legal element of a capture set", ann.srcPos)
115115
case ref: CoreCapability =>
116-
if !ref.isTrackableRef && !ref.isCapRef then
116+
if !ref.isTrackableRef && !ref.isCapRef && !ctx.mode.is(Mode.ReadPositions) then
117117
report.error(em"$elem cannot be tracked since it is not a parameter or local value", ann.srcPos)
118118
case ReachCapability(ref) =>
119119
check(ref)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ object SymDenotations {
20532053
case p :: parents1 =>
20542054
p.classSymbol match {
20552055
case pcls: ClassSymbol => builder.addAll(pcls.baseClasses)
2056-
case _ => assert(isRefinementClass || p.isError || ctx.mode.is(Mode.Interactive) || ctx.tolerateErrorsForBestEffort, s"$this has non-class parent: $p")
2056+
case _ => assert(isRefinementClass || p.isError || ctx.mode.is(Mode.Interactive) || ctx.tolerateErrorsForBestEffort || ctx.mode.is(Mode.ReadPositions), s"$this has non-class parent: $p")
20572057
}
20582058
traverse(parents1)
20592059
case nil =>

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ trait Checking {
16871687
val tname = sym.targetName
16881688
if tname != sym.name then
16891689
val preExisting = ctx.effectiveScope.lookup(tname)
1690-
if preExisting.exists || seen.contains(tname) then
1690+
if (preExisting.exists || seen.contains(tname)) && !ctx.mode.is(Mode.ReadPositions) then
16911691
report.error(em"@targetName annotation ${'"'}$tname${'"'} clashes with other definition in same scope", stat.srcPos)
16921692
if stat.isDef then seen += tname
16931693

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ trait Implicits:
10981098
def inferImplicit(pt: Type, argument: Tree, span: Span, ignored: Set[Symbol] = Set.empty)(using Context): SearchResult = ctx.profiler.onImplicitSearch(pt):
10991099
trace(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}", implicits, show = true) {
11001100
record("inferImplicit")
1101-
assert(ctx.phase.allowsImplicitSearch,
1101+
assert(ctx.phase.allowsImplicitSearch || ctx.mode.is(Mode.ReadPositions),
11021102
if (argument.isEmpty) i"missing implicit parameter of type $pt after typer at phase ${ctx.phase}"
11031103
else i"type error: ${argument.tpe} does not conform to $pt${err.whyNoMatchStr(argument.tpe, pt)}")
11041104

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3287,7 +3287,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
32873287
selfType.member(decl.name).symbol.filter(other => other.isClass && other.owner != cls)
32883288
decls.iterator.filter(_.isType).foldLeft(false) { (foundRedef, decl) =>
32893289
val other = memberInSelfButNotThis(decl)
3290-
if (other.exists) {
3290+
if (other.exists && !ctx.mode.is(Mode.ReadPositions)) {
32913291
val msg = CannotHaveSameNameAs(decl, other, CannotHaveSameNameAs.DefinedInSelf(self))
32923292
report.error(msg, decl.srcPos)
32933293
}

0 commit comments

Comments
 (0)