Skip to content

Commit 18222b7

Browse files
committed
tweak tests, add limitation errors
After the fix of the soundness issue, sometimes we infer universal capabilities where it is not necessary. This results in completeness issues.
1 parent 8c90908 commit 18222b7

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

tests/pos-custom-args/captures/boxmap.scala renamed to tests/neg-custom-args/boxmap.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ def lazymap[A <: Top, B <: Top](b: Box[A])(f: A => B): {f} (() -> Box[B]) =
1515
def test[A <: Top, B <: Top] =
1616
def lazymap[A <: Top, B <: Top](b: Box[A])(f: A => B) =
1717
() => b[Box[B]]((x: A) => box(f(x)))
18-
val x: (b: Box[A]) -> (f: A => B) -> (() -> Box[B]) = lazymap[A, B]
18+
val x0: (b: Box[A]) -> (f: A => B) -> (() -> Box[B]) = lazymap[A, B] // error
19+
val x: (b: Box[A]) -> (f: A => B) -> {f} (() -> Box[B]) = lazymap[A, B] // error // limitation
20+
val y: (b: Box[A]) -> (f: A => B) -> {*} (() -> Box[B]) = lazymap[A, B] // works
1921
()

tests/pos-custom-args/captures/lazyref.scala renamed to tests/neg-custom-args/captures/lazyref-pos.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def map[A, B](ref: {*} LazyRef[A], f: A => B): {f, ref} LazyRef[B] =
99
new LazyRef(() => f(ref.elem()))
1010

1111
def mapc[A, B]: (ref: {*} LazyRef[A], f: A => B) => {f, ref} LazyRef[B] =
12-
(ref1, f1) => map[A, B](ref1, f1)
12+
(ref1, f1) => map[A, B](ref1, f1) // error // limitation
1313

1414
def test(cap1: Cap, cap2: Cap) =
1515
def f(x: Int) = if cap1 == cap1 then x else 0

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:13:2 ---------------------------------------
2+
13 | (ref1, f1) => map[A, B](ref1, f1) // error // limitation
3+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
| Found: ? (ref1: {*} LazyRef[? A]{elem: {*} () -> box ? A}, f1: {*} (x$0: ? A) -> ? B) ->
5+
| {f1, ref1, *} LazyRef[? B]{elem: {*} () -> box ? B}
6+
| Required: (ref: {*} LazyRef[A], f: A => B) -> {f, ref} LazyRef[B]
7+
|
8+
| longer explanation available when compiling with `-explain`
19
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazyref.scala:19:28 --------------------------------------
210
19 | val ref1c: LazyRef[Int] = ref1 // error
311
| ^^^^

tests/neg-custom-args/captures/lazyref.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def map[A, B](ref: {*} LazyRef[A], f: A => B): {f, ref} LazyRef[B] =
1010
new LazyRef(() => f(ref.elem()))
1111

1212
def mapc[A, B]: (ref: {*} LazyRef[A], f: A => B) -> {f, ref} LazyRef[B] =
13-
(ref1, f1) => map[A, B](ref1, f1)
13+
(ref1, f1) => map[A, B](ref1, f1) // error // limitation
1414

1515
def test(cap1: Cap, cap2: Cap) =
1616
def f(x: Int) = if cap1 == cap1 then x else 0

0 commit comments

Comments
 (0)