Skip to content

Commit d2d529e

Browse files
committed
Tighten existential subsume rules further:
Also drop existential instances subsuming Fresh instances.
1 parent b17ef26 commit d2d529e

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ trait CaptureRef extends TypeProxy, ValueType:
265265
case Existential.Vble(binder) =>
266266
y.stripReadOnly match
267267
case Existential.Vble(binder1) => false
268+
case Fresh(_) => false
268269
case _ => true
269270
case _ =>
270271
this.isCap && !yIsExistential && canAddHidden && vs != VarState.HardSeparate

tests/neg-custom-args/captures/cc-existential-conformance.check

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
| x² is a reference to a value parameter
99
|
1010
| longer explanation available when compiling with `-explain`
11+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:9:29 --------------------
12+
9 | val z: A -> (x: A) -> B^ = y // error
13+
| ^
14+
| Found: (y : A -> A -> B^)
15+
| Required: A -> (x: A) -> B^
16+
|
17+
| longer explanation available when compiling with `-explain`
1118
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:13:19 -------------------
1219
13 | val y: Fun[B^] = x // error
1320
| ^
@@ -18,3 +25,10 @@
1825
| x² is a reference to a value parameter
1926
|
2027
| longer explanation available when compiling with `-explain`
28+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/cc-existential-conformance.scala:14:24 -------------------
29+
14 | val z: (x: A) -> B^ = y // error
30+
| ^
31+
| Found: (y : A -> B^)
32+
| Required: (x: A) -> B^
33+
|
34+
| longer explanation available when compiling with `-explain`

tests/neg-custom-args/captures/cc-existential-conformance.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ type Fun[T] = A -> T
66
def test() =
77
val x: A -> (x: A) -> B^ = ???
88
val y: A -> Fun[B^] = x // error
9-
val z: A -> A -> B^ = y // ok
9+
val z: A -> (x: A) -> B^ = y // error
1010

1111
def test2() =
1212
val x: (x: A) -> B^ = ???
1313
val y: Fun[B^] = x // error
14-
val z: A -> B^ = y // ok
14+
val z: (x: A) -> B^ = y // error

0 commit comments

Comments
 (0)