Skip to content

Commit 76482c4

Browse files
committed
Refine condition when to not typecheck again
Only count errors that lead to an error type in some subtree as unrecoverable.
1 parent d15dd2d commit 76482c4

File tree

6 files changed

+20
-21
lines changed

6 files changed

+20
-21
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,10 @@ object ProtoTypes {
344344
case _ => false
345345
}
346346

347-
/** Did an argument produce an error when typing? */
347+
/** Did an argument produce an error when typing? This means: an error was reported
348+
* and a tree got an error type. Errors of adaptation whree a tree has a good type
349+
* but that type does not conform to the expected type are not counted.
350+
*/
348351
def hasErrorArg = !state.errorArgs.isEmpty
349352

350353
private def cacheTypedArg(arg: untpd.Tree, typerFn: untpd.Tree => Tree, force: Boolean)(using Context): Tree = {
@@ -363,7 +366,7 @@ object ProtoTypes {
363366
targ = arg.withType(WildcardType)
364367
case _ =>
365368
targ = typerFn(arg)
366-
if ctx.reporter.hasUnreportedErrors then
369+
if ctx.reporter.hasUnreportedErrors && targ.existsSubTree(_.tpe.isError) then
367370
state.errorArgs += arg
368371
else
369372
state.typedArg = state.typedArg.updated(arg, targ)

tests/neg-custom-args/deprecation/t3235-minimal-v2.check

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/neg-custom-args/deprecation/t3235-minimal-v2.scala

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/neg-custom-args/deprecation/t3235-minimal-v3.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/neg-custom-args/deprecation/t3235-minimal.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,15 @@
22
3 | assert(123456789.round == 123456789) // error
33
| ^^^^^^^^^^^^^^^
44
|method round in class RichInt is deprecated since 2.11.0: this is an integer type; there is no reason to round it. Perhaps you meant to call this on a floating-point value?
5+
-- Error: tests/neg-custom-args/deprecation/t3235-minimal.scala:4:16 ---------------------------------------------------
6+
4 | assert(math.round(123456789) == 123456789) // error
7+
| ^^^^^^^^^^
8+
|method round in package scala.math is deprecated since 2.11.0: This is an integer type; there is no reason to round it. Perhaps you meant to call this with a floating-point value?
9+
-- Error: tests/neg-custom-args/deprecation/t3235-minimal.scala:5:32 ---------------------------------------------------
10+
5 | assert(1234567890123456789L.round == 1234567890123456789L) // error
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
|method round in class RichLong is deprecated since 2.11.0: this is an integer type; there is no reason to round it. Perhaps you meant to call this on a floating-point value?
13+
-- Error: tests/neg-custom-args/deprecation/t3235-minimal.scala:6:16 ---------------------------------------------------
14+
6 | assert(math.round(1234567890123456789L) == 1234567890123456789L) // error
15+
| ^^^^^^^^^^
16+
|method round in package scala.math is deprecated since 2.11.0: This is an integer type; there is no reason to round it. Perhaps you meant to call this with a floating-point value?
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
object Test {
22
def main(args: Array[String]): Unit = {
33
assert(123456789.round == 123456789) // error
4+
assert(math.round(123456789) == 123456789) // error
5+
assert(1234567890123456789L.round == 1234567890123456789L) // error
6+
assert(math.round(1234567890123456789L) == 1234567890123456789L) // error
47
}
58
}

0 commit comments

Comments
 (0)