-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Carry and check universal capability from parents correctly (#20004)
Fix #18857 This PR checks universal capability from parent classes properly.
- Loading branch information
Showing
6 changed files
with
77 additions
and
14 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
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
15 changes: 15 additions & 0 deletions
15
tests/neg-custom-args/captures/extending-cap-classes.scala
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,15 @@ | ||
import annotation.capability | ||
|
||
class C1 | ||
@capability class C2 extends C1 | ||
class C3 extends C2 | ||
|
||
def test = | ||
val x1: C1 = new C1 | ||
val x2: C1 = new C2 // error | ||
val x3: C1 = new C3 // error | ||
|
||
val y1: C2 = new C2 | ||
val y2: C2 = new C3 | ||
|
||
val z1: C3 = new C3 |
30 changes: 30 additions & 0 deletions
30
tests/neg-custom-args/captures/extending-impure-function.scala
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,30 @@ | ||
class F1 extends (Int => Unit) { | ||
def apply(x: Int): Unit = () | ||
} | ||
|
||
class F2 extends (Int -> Unit) { | ||
def apply(x: Int): Unit = () | ||
} | ||
|
||
def test = | ||
val x1 = new (Int => Unit) { | ||
def apply(x: Int): Unit = () | ||
} | ||
|
||
val x2: Int -> Unit = new (Int => Unit) { // error | ||
def apply(x: Int): Unit = () | ||
} | ||
|
||
val x3: Int -> Unit = new (Int -> Unit) { | ||
def apply(x: Int): Unit = () | ||
} | ||
|
||
val y1: Int => Unit = new F1 | ||
val y2: Int -> Unit = new F1 // error | ||
val y3: Int => Unit = new F2 | ||
val y4: Int -> Unit = new F2 | ||
|
||
val z1 = () => () | ||
val z2: () -> Unit = () => () | ||
val z3: () -> Unit = z1 | ||
val z4: () => Unit = () => () |