Skip to content
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

Support withScope() in AutoDisposeDetector #378

Merged
merged 5 commits into from
Sep 18, 2019
Merged

Conversation

ZacSweers
Copy link
Collaborator

This adds support for the new withScope() API in AutoDisposeDetector. This works by detecting when that function is called, and then visits the contents of the lambda argument passed to it with the same machinery we used before. This refactors out that machinery a bit to allow defining a custom "isInScope" check, and in the case of withScope() it's just hardcoded to true when it checks if an enclosed subscribe() call is made in a scope

This allows for users to call return or other escapes within its context
method.containingClass?.qualifiedName == KOTLIN_EXTENSIONS) {
val args = node.valueArguments
if (args.size == 2) {
val last = args[1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can also do args.last() i believe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That does an extra size check, which we can skip in this case

@ZacSweers ZacSweers merged commit fbfdbbf into master Sep 18, 2019
@ZacSweers ZacSweers deleted the z/withScopeLint branch September 18, 2019 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants