-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canonicalize capture variable subtype comparisons #22299
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import language.experimental.captureChecking | ||
import caps.* | ||
|
||
def test[C^] = | ||
val a: C = ??? | ||
val b: CapSet^{C^} = a | ||
val c: C = b | ||
val d: CapSet^{C^, c} = a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, we should never have an instance of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The point of this is to test subtyping relations between capture sets. The term bindings are a crutch. Back then I could not do it in the "obvious" way using e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the assignments are fine to test. I mean the |
||
|
||
// TODO: make "CapSet-ness" of type variables somehow contagious? | ||
// Then we don't have to spell out the bounds explicitly... | ||
def testTrans[C^, D >: CapSet <: C, E >: CapSet <: D, F >: C <: CapSet^] = | ||
val d1: D = ??? | ||
val d2: CapSet^{D^} = d1 | ||
val d3: D = d2 | ||
val e1: E = ??? | ||
val e2: CapSet^{E^} = e1 | ||
val e3: E = e2 | ||
val d4: D = e1 | ||
val c1: C = d1 | ||
val c2: C = e1 | ||
val f1: F = c1 | ||
val d_e_f1: CapSet^{D^,E^,F^} = d1 | ||
val d_e_f2: CapSet^{D^,E^,F^} = e1 | ||
val d_e_f3: CapSet^{D^,E^,F^} = f1 | ||
val f2: F = d_e_f1 | ||
val c3: C = d_e_f1 // error | ||
val c4: C = f1 // error | ||
val e4: E = f1 // error | ||
val e5: E = d1 // error | ||
val c5: CapSet^{C^} = e1 | ||
|
||
|
||
trait A[+T] | ||
|
||
trait B[-C] | ||
|
||
def testCong[C^, D^] = | ||
val a: A[C] = ??? | ||
val b: A[CapSet^{C^}] = a | ||
val c: A[CapSet^{D^}] = a // error | ||
val d: A[CapSet^{C^,D^}] = a | ||
val e: A[C] = d // error | ||
val f: B[C] = ??? | ||
val g: B[CapSet^{C^}] = f | ||
val h: B[C] = g | ||
val i: B[CapSet^{C^,D^}] = h // error | ||
val j: B[C] = i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this condition check
this
instead ofinfo
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case here does not look currect for me.
viaInfo
is used only if there is some equivalent relation from singleton types.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's tailored to the case that we want to check that a term variable reaches a capture variable (resp. the capture variable subsumes the term variable, so we check the
this
), because of the issue outlined in#22299 (comment)
Not sure if this is best place to do it, but logically we have to chase along the infos of the context entries. The
case y: TermRef if !y.isRootCapability =>
part will invoke this function as a last resort, and since we have to follow the info then, we might as well do it here.Feel free to open a new PR if you see a better way to do it.