-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sealed refs test and fix check files of other tests
- Loading branch information
Showing
6 changed files
with
60 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
|
||
-- Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:2:6 -------------------------------------------------------- | ||
-- Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:3:8 -------------------------------------------------------- | ||
3 | this: D^ => // error | ||
| ^^ | ||
|reference (caps.cap : caps.Cap) captured by this self type is not included in the allowed capture set {} of pure base class class C | ||
-- [E058] Type Mismatch Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:2:6 ----------------------------------- | ||
2 |class D extends C: // error | ||
|^ | ||
|reference (caps.cap : caps.Cap) is not included in the allowed capture set {} of pure base class class C | ||
3 | this: D^ => | ||
| ^ | ||
| illegal inheritance: self type D^ of class D does not conform to self type C | ||
| of parent class C | ||
| | ||
| longer explanation available when compiling with `-explain` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
class D extends C: // error | ||
this: D^ => | ||
this: D^ => // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class Ref[sealed A](init: A): | ||
this: Ref[A]^ => | ||
private var x: A = init | ||
def get: A = x | ||
def set(x: A): Unit = this.x = x | ||
|
||
class It[X]: | ||
this: It[X]^ => | ||
|
||
def f1[B1](x: B1, next: B1 -> B1) = | ||
var r = x // ok | ||
r = next(x) | ||
r | ||
|
||
def f2[B2](x: B2, next: B2 -> B2) = | ||
val r = Ref[B2](x) // error | ||
r.set(next(x)) | ||
r.get | ||
|
||
def g[sealed B](x: B, next: B -> B) = | ||
val r = Ref[B](x) // ok | ||
r.set(next(x)) | ||
r.get | ||
|
||
import annotation.unchecked.uncheckedCaptures | ||
|
||
def h[B](x: B, next: B -> B) = | ||
val r = Ref[B @uncheckedCaptures](x) // ok | ||
r.set(next(x)) | ||
r.get | ||
|
||
def f3[B](x: B, next: B -> B) = | ||
val r: Ref[B^{cap[f3]}] = Ref[B^{cap[f3]}](x) // error | ||
r.set(next(x)) | ||
val y = r.get | ||
() | ||
|
||
def f4[B](x: B, next: B -> B) = | ||
val r: Ref[B]^{cap[f4]} = Ref[B](x) // error | ||
r.set(next(x)) | ||
val y = r.get | ||
() |