Open
Description
Minimized code
import language.experimental.captureChecking
class A:
val m: A^ = this
def test(a: A^, b: A^) =
type at = a.type
val c1: at^{b} = a
val c2: c1.type = a
Output
-- [E007] Type Mismatch Error: Stest.scala:207:19 ------------------------------
207 | val c1: at^{b} = a
| ^
| Found: (a : A^)
| Required: at^{b}
|---------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| Tree: a
| I tried to show that
| (a : A^)
| conforms to
| at^{b}
| but none of the attempts shown below succeeded:
|
| ==> (a : A^) <: at^{b}
| ==> A^{a} <: at^{b}
| ==> A <: at^{b}
| ==> A <: at
| ==> A <: (a : A^) = false
|
| The tests were made under the empty constraint
---------------------------------------------------------------------------
1 error found
Expectation
Although we cannot attach a capture set to a singleton type directly, this check can be easily bypassed by declaring a type alias or substitution.
This example should compile.