Skip to content

Commit 3e690a8

Browse files
committed
remove markSolved
1 parent 0cf2f20 commit 3e690a8

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,6 @@ class CheckCaptures extends Recheck, SymTransformer:
630630
if (ares1 eq ares) && (aargs1 eq aargs) then actual
631631
else reconstruct(aargs1, ares1)
632632

633-
curEnv.captured.asVar.markSolved()
634633
(resTp, curEnv.captured)
635634
finally
636635
curEnv = saved
@@ -656,7 +655,6 @@ class CheckCaptures extends Recheck, SymTransformer:
656655
if ares1 eq ares then actual
657656
else reconstruct(ares1)
658657

659-
curEnv.captured.asVar.markSolved()
660658
(resTp, curEnv.captured)
661659
finally
662660
curEnv = saved

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
633633
case (info1: MethodType, info2: MethodType) =>
634634
matchingMethodParams(info1, info2, precise = false)
635635
&& isSubInfo(info1.resultType, info2.resultType.subst(info2, info1))
636+
case (info1 @ CapturingType(parent1, refs1), info2: Type) =>
637+
subCaptures(refs1, info2.captureSet, frozenConstraint).isOK && sameBoxed(info1, info2, refs1)
638+
&& isSubInfo(parent1, info2)
639+
case (info1: Type, CapturingType(parent2, refs2)) =>
640+
val refs1 = info1.captureSet
641+
(refs1.isAlwaysEmpty || subCaptures(refs1, refs2, frozenConstraint).isOK) && sameBoxed(info1, info2, refs1)
642+
&& isSubInfo(info1, parent2)
636643
case _ =>
637644
isSubType(info1, info2)
638645

tests/neg-custom-args/captures/curried-simplified.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@
1515
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/curried-simplified.scala:11:39 ---------------------------
1616
11 | def y3: Cap -> Protect[Int -> Int] = x3 // error
1717
| ^^
18-
| Found: (x$0: Cap) -> {x$0} Int -> Int
18+
| Found: ? (x$0: Cap) -> {x$0} Int -> Int
1919
| Required: Cap -> Protect[Int -> Int]
2020
|
2121
| longer explanation available when compiling with `-explain`
2222
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/curried-simplified.scala:15:33 ---------------------------
2323
15 | def y5: Cap -> {} Int -> Int = x5 // error
2424
| ^^
25-
| Found: Cap -> {x} Int -> Int
25+
| Found: ? Cap -> {x} Int -> Int
2626
| Required: Cap -> {} Int -> Int
2727
|
2828
| longer explanation available when compiling with `-explain`
2929
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/curried-simplified.scala:17:49 ---------------------------
3030
17 | def y6: Cap -> {} Cap -> Protect[Int -> Int] = x6 // error
3131
| ^^
32-
| Found: (x$0: Cap) -> {x$0} (x$0: Cap) -> {x$0, x$0} Int -> Int
33-
| Required: Cap -> {} Cap -> Protect[Int -> Int]
32+
| Found: ? (x$0: Cap) -> {x$0} (x$0: Cap) -> {x$0, x$0} Int -> Int
33+
| Required: Cap -> {} Cap -> Protect[Int -> Int]
3434
|
3535
| longer explanation available when compiling with `-explain`
3636
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/curried-simplified.scala:19:49 ---------------------------
3737
19 | def y7: Cap -> Protect[Cap -> {} Int -> Int] = x7 // error
3838
| ^^
39-
| Found: (x$0: Cap) -> {x$0} (x: Cap) -> {x$0, x} Int -> Int
39+
| Found: ? (x$0: Cap) -> {x$0} (x: Cap) -> {x$0, x} Int -> Int
4040
| Required: Cap -> Protect[Cap -> {} Int -> Int]
4141
|
4242
| longer explanation available when compiling with `-explain`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/eta.scala:4:9 --------------------------------------------
22
4 | g // error
33
| ^
4-
| Found: (g : () -> A)
4+
| Found: ? () -> A
55
| Required: () -> {f} Proc
66
|
77
| longer explanation available when compiling with `-explain`

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:23:27 ------------------------------------------------------
22
23 | val later = usingLogFile { f => () => f.write(0) } // error
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^
4-
| {f, *} () -> Unit cannot be box-converted to box ? () -> Unit
4+
| {f} () -> Unit cannot be box-converted to box ? () -> Unit
55
| since one of their capture sets contains the root capability `*`
66
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:29:9 -------------------------------------------------------
77
29 | later2.x() // error
@@ -21,15 +21,15 @@
2121
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:47:27 ------------------------------------------------------
2222
47 | val later = usingLogFile { f => () => f.write(0) } // error
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^
24-
| {f, *} () -> Unit cannot be box-converted to box ? () -> Unit
24+
| {f} () -> Unit cannot be box-converted to box ? () -> Unit
2525
| since one of their capture sets contains the root capability `*`
2626
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:62:33 ------------------------------------------------------
2727
62 | val later = usingFile("out", f => (y: Int) => xs.foreach(x => f.write(x + y))) // error
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29-
| {f, *} (x$0: Int) -> Unit cannot be box-converted to box ? (x$0: Int) -> Unit
29+
| {f} (x$0: Int) -> Unit cannot be box-converted to box ? (x$0: Int) -> Unit
3030
| since one of their capture sets contains the root capability `*`
3131
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:71:37 ------------------------------------------------------
3232
71 | val later = usingFile("logfile", usingLogger(_, l => () => l.log("test"))) // error
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34-
| {_$1, *} () -> Unit cannot be box-converted to box ? () -> Unit
34+
| {_$1} () -> Unit cannot be box-converted to box ? () -> Unit
3535
| since one of their capture sets contains the root capability `*`

0 commit comments

Comments
 (0)