Skip to content

Commit 3ab65ae

Browse files
authored
Merge pull request #6103 from dotty-staging/fix-#6059
Fix #6059: Use correct errors-reported condition in Desugar
2 parents 5eca323 + 48be47d commit 3ab65ae

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ object desugar {
13631363
AppliedTypeTree(ref(seqType), t),
13641364
New(ref(defn.RepeatedAnnotType), Nil :: Nil))
13651365
} else {
1366-
assert(ctx.mode.isExpr || ctx.reporter.hasErrors || ctx.mode.is(Mode.Interactive), ctx.mode)
1366+
assert(ctx.mode.isExpr || ctx.reporter.errorsReported || ctx.mode.is(Mode.Interactive), ctx.mode)
13671367
Select(t, op.name)
13681368
}
13691369
case PrefixOp(op, t) =>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ object Phases {
287287

288288
def isRunnable(implicit ctx: Context): Boolean =
289289
!ctx.reporter.hasErrors
290+
// TODO: This might test an unintended condition.
291+
// To find out whether any errors have been reported during this
292+
// run one calls `errorsReported`, not `hasErrors`.
293+
// But maybe changing this would prevent useful phases from running?
290294

291295
/** If set, allow missing or superfluous arguments in applications
292296
* and type applications.

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ trait Reporting { this: Context =>
9898
else reportWarning(new ExtendMessage(() => msg)(_ + "\n(This would be an error under strict mode)").warning(fullPos))
9999
}
100100

101-
def error(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit =
101+
def error(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = {
102102
reporter.report(new Error(msg, addInlineds(pos)))
103+
}
103104

104105
def errorOrMigrationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = {
105106
val fullPos = addInlineds(pos)
@@ -184,11 +185,22 @@ abstract class Reporter extends interfaces.ReporterResult {
184185

185186
private[this] var _errorCount = 0
186187
private[this] var _warningCount = 0
188+
189+
/** The number of errors reported by this reporter (ignoring outer reporters) */
187190
def errorCount: Int = _errorCount
191+
192+
/** The number of warnings reported by this reporter (ignoring outer reporters) */
188193
def warningCount: Int = _warningCount
194+
195+
/** Have errors been reported by this reporter (ignoring outer reporters)? */
189196
def hasErrors: Boolean = errorCount > 0
197+
198+
/** Have warnings been reported by this reporter (ignoring outer reporters)? */
190199
def hasWarnings: Boolean = warningCount > 0
200+
191201
private[this] var errors: List[Error] = Nil
202+
203+
/** All errors reported by this reporter (ignoring outer reporters) */
192204
def allErrors: List[Error] = errors
193205

194206
/** Have errors been reported by this reporter, or in the

tests/neg/i6059.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def I0(I1: Int ) = I1
2+
val I1 = I0(I0 i2 // error
3+
) => true

0 commit comments

Comments
 (0)