Skip to content

Commit 25f0f71

Browse files
committed
Skip closure nodes when checking conformance
1 parent 6c14f81 commit 25f0f71

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

compiler/src/dotty/tools/dotc/transform/Recheck.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ abstract class Recheck extends Phase, IdentityDenotTransformer:
310310
end recheck
311311

312312
def checkConforms(tpe: Type, pt: Type, tree: Tree)(using Context): Unit = tree match
313-
case _: DefTree | EmptyTree | _: TypeTree =>
313+
case _: DefTree | EmptyTree | _: TypeTree | _: Closure =>
314+
// Don't report closure nodes, since their span is a point; wait instead
315+
// for enclosing block to preduce an error
314316
case _ =>
315317
val actual = tpe.widenExpr
316318
val expected = pt.widenExpr

tests/neg-custom-args/captures/boxmap.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/boxmap.scala:14:5 ----------------------------------------
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/boxmap.scala:14:2 ----------------------------------------
22
14 | () => b[Box[B]]((x: A) => box(f(x))) // error
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
| Found: {f} () => Box[B]

tests/neg-custom-args/captures/capt1.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:3:5 ------------------------------------------
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:3:2 ------------------------------------------
22
3 | () => if x == null then y else y // error
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
| Found: {x} () => C
55
| Required: () => C
66

77
longer explanation available when compiling with `-explain`
8-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:6:5 ------------------------------------------
8+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:6:2 ------------------------------------------
99
6 | () => if x == null then y else y // error
1010
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1111
| Found: {x} () => C
@@ -33,7 +33,7 @@ longer explanation available when compiling with `-explain`
3333
| Required: A
3434

3535
longer explanation available when compiling with `-explain`
36-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:32:27 ----------------------------------------
36+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:32:24 ----------------------------------------
3737
32 | val z2 = h[() => Cap](() => x)(() => C()) // error
3838
| ^^^^^^^
3939
| Found: {x} () => Cap

tests/neg-custom-args/captures/try.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:29:35 ------------------------------------------
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:29:32 ------------------------------------------
22
29 | (x: CanThrow[Exception]) => () => raise(new Exception)(using x) // error
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
| Found: {x} () => Nothing
55
| Required: () => Nothing
66

77
longer explanation available when compiling with `-explain`
8-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:36:9 -------------------------------------------
8+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:36:6 -------------------------------------------
99
36 | () => // error
1010
| ^
1111
| Found: {x} () => Int
@@ -14,7 +14,7 @@ longer explanation available when compiling with `-explain`
1414
38 | 22
1515

1616
longer explanation available when compiling with `-explain`
17-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:47:7 -------------------------------------------
17+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/try.scala:47:4 -------------------------------------------
1818
47 | () => // error
1919
| ^
2020
| Found: {x} () => Int

0 commit comments

Comments
 (0)