-
Couldn't load subscription status.
- Fork 664
[javac plugin] Add compile-time checks for unsafe or incorrect coroutine usage #8289
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
Open
SamCarlberg
wants to merge
11
commits into
wpilibsuite:2027
Choose a base branch
from
SamCarlberg:compiler-plugin-coroutine-yield-check
base: 2027
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[javac plugin] Add compile-time checks for unsafe or incorrect coroutine usage #8289
SamCarlberg
wants to merge
11
commits into
wpilibsuite:2027
from
SamCarlberg:compiler-plugin-coroutine-yield-check
+1,796
−14
Conversation
This file contains hidden or 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
Only locally bound coroutine objects are valid to yield on; eg, with nested lambdas, a loop in the innermost lambda may only use coroutines defined by that innermost lambda Maybe we should also check for inner lambdas invoking methods on captured coroutines from the enclosing scope, since those coroutines may not be mounted when the inner lambda runs
5f26745 to
b65df19
Compare
commandsv3/src/test/java/org/wpilib/commands3/CoroutineTest.java
Outdated
Show resolved
Hide resolved
javacPlugin/src/main/java/org/wpilib/javacplugin/CodeAfterCoroutineParkDetector.java
Outdated
Show resolved
Hide resolved
javacPlugin/src/main/java/org/wpilib/javacplugin/CoroutineYieldInLoopDetector.java
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
2027
2027 target
component: commands v3
WPILib commands library version 3
component: javac plugin
Java compiler plugin
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CoroutineYieldInLoopDetector
This checks for
whileloops where coroutines are in scope but without calling a blocking method on at least one of those coroutines:Note that, because we assume most looping constructs in commands will use while loops, we don't check for-loops, for-each loops, or do-while loops.
This check can be disabled with
@SuppressWarnings("CoroutineYieldInLoop")CodeAfterCoroutineParkDetector
Essentially acts like the Java compiler's check for code after a
while (true)loop, but forcoroutine.park():This check can be disabled with
@SuppressWarnings("CodeAfterCoroutinePark")IncorrectCoroutineUseDetector
Checks for usage of captured (outer) coroutine parameters and assignments to fields.
This check can be disabled with
@SuppressWarnings("CoroutineMayNotBeInScope")This check can be disabled with
@SuppressWarnings("CoroutineCapture")