Skip to content

Add doc page for capture checking. #14438

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

Merged
merged 1 commit into from
Feb 8, 2022
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Feb 8, 2022

Add doc page that explains what capture checking is, emphasizing that
it is still a research project in a separate branch.

Add doc page that explains what capture checking is, emphasizing that
it is still a research project in a separate branch.
@odersky odersky merged commit 492ccae into scala:main Feb 8, 2022
@odersky odersky deleted the cc-doc-page branch February 8, 2022 20:01
Comment on lines +336 to +337
val x: A = this
def f = println(c) // error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not completely clear on this example, if f was defined before x, would that change the inferred type for this and lead to an error when typing x?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. You get:

16 |    val x: A = this
   |               ^^^^
   |               Found:    (A.this : {c} A)
   |               Required: A

private var forced = false
private var cache: {this} LzyList[A] = uninitialized
private def force =
if !forced then { cache = tl(); forced = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that {*} LzyList[A] <: {this} LzyList[A] ? How does this follow exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's more subtle. See #14387

I still need to work that in the discussion here somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants