Repository navigation
Move PICO to EISOP - #1013
Open
aosen-xiong wants to merge 267 commits into
Open
Move PICO to EISOP#1013aosen-xiong wants to merge 267 commits into
aosen-xiong wants to merge 267 commits into
Conversation
aosen-xiong
force-pushed
the
pico-move
branch
from
December 14, 2024 19:35
33dfd50 to
32a297b
Compare
wmdietl
requested changes
Dec 20, 2024
wmdietl
left a comment
Member
There was a problem hiding this comment.
A quick round of initial comments.
aosen-xiong
commented
Dec 27, 2024
…hod parameters are not
aosen-xiong
commented
Dec 31, 2024
|
|
||
| this.assignableReadonlyField = rdmObject; | ||
| // :: error: (assignment.type.incompatible) :: error: (illegal.field.write) | ||
| this.rdmField = rdmObject; // Field is adpated to immutable but method parameters are not? |
Collaborator
Author
There was a problem hiding this comment.
This is wrong, method parameter should also be adapted. #1037
Collaborator
Author
There was a problem hiding this comment.
visitMethod is getting its oracle in AnnotatedExecutableType methodType = atypeFactory.getAnnotatedType(tree).deepCopy();. It should get adapated version of the original method signature.
Collaborator
Author
|
|
aosen-xiong
commented
Aug 4, 2026
aosen-xiong
commented
Aug 4, 2026
Replace TypesUtils.isAnonymous(TreeUtils.typeOf(...)) with TreeUtils.isAnonymousClass(ClassTree) in MutabilityNoInitVisitor and MutabilityValidator, following the API unification in eisop#1909 which fixes a JDK 11 anonymous class detection bug.
Java enums can have mutable fields, so @mutable on enum declarations is a valid use case. The existing defaulting (MutabilityEnumDefaultAnnotator) already handles this correctly via addMissingAnnotations. Added a Counter enum test case demonstrating mutable enum with mutable state.
Replace actionable TODO with descriptive comment explaining that the modern builder pattern (mutating target via setters) correctly reports illegal.field.write and would require uniqueness tracking to support.
No custom poly.invocation.error key needed — the generic assignment.type.incompatible is correct for poly return constrained by receiver mutability. Chained poly calls (test5) correctly error since each poly return resolves based on the receiver's mutability.
In @immutable ObjectMethods2, annotate clone() return type as @immutable Object instead of using SuppressWarnings workaround. The override.return.invalid remains (consistent with all three test classes) due to how Object.clone() is annotated in stubs.
Replace the TODO with a descriptive comment explaining that varargs type inference with @PolyMutable (e.g. Arrays.asList) does not correctly adapt to the required mutability context, causing a false positive that requires @SuppressWarnings.
Convert actionable TODOs into a descriptive note explaining that the test is skipped because PICO lacks postcondition qualifiers (like @EnsuresAssigned), preventing it from verifying initialization via helper methods.
Add method calls with assertions to LocalVariableRefinement.java foo() to test that local variable mutability flow refinement is correctly applied after reassignment.
Update MutabilityNoInitVisitor to strictly check that constructors can only initialize fields declared in their own class. Reassigning inherited fields is now forbidden since the superclass constructor has already completed and its state should not be mutated. Added illegal.field.write expectation to SuperClassTest.java.
Update MemoizedRectangle.java to replace the TODO with a comment explaining why no override error is emitted: mutating an @Assignable field does not require a @mutable receiver. Also explicitly annotated the receiver of size() as @readonly to make it clear why it validly overrides the superclass method.
Make inner classes static in ImplicitMutable.java. In Java 11, non-static inner classes cannot declare static fields, which was causing a compilation error in the test suite.
The test was skipped because the Initialization Checker had no postcondition qualifier, so a constructor that delegates field initialization to helper methods reported initialization.fields.uninitialized. eisop#1918 added @EnsuresInitialized; annotate the three helpers with it and un-skip the test. The field writes also need an immutable value: `new Object()` yields a @mutable instance, which cannot be assigned to a field of an @immutable class. The test now type-checks with no expected diagnostics at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…method Calling a @ReceiverDependentMutable method through a @readonly receiver adapts the method's type parameter bound to @MutabilityLost, which is already reported as mutability.lost.in.bounds. When the call also passes an argument and the type parameter is not instantiated explicitly, the parameter's type is the uninstantiated type variable, so the same lost bound is reported a second time as mutability.lost.parameter. The neighboring calls show the two errors share that one cause: methodWithNoArgs has no parameter and reports only the bound error, and an explicit <@mutable Object> type argument instantiates the variable away from the lost bound and reports type.argument.type.incompatible instead. Record the current behavior. Whether the parameter check should skip a type variable whose only lost qualifier comes from its bound is a separate question. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The test reads on its own; the history records why it was skipped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merging master broke compilation of the Mutability Checker: `DefaultQualifierForUseTypeAnnotator.getDefaultAnnosForUses` is now public, and `AbstractViewpointAdapter` gained the abstract `extractAnnotationMirror(AnnotationMirrorSet)`. Widen the override to public, and implement the new method by finding the qualifier in the mutability hierarchy. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Master moved the Spotless configuration from build.gradle into buildSrc/src/main/groovy/cf-spotless.gradle; carry the branch's extra formatAnnotations type annotations over to it. Master also dropped the TEX_FILES list from docs/manual/Makefile, so the branch's entry for mutability-checker.tex is no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The override skipped super.postDirectSuperTypes because viewpoint adaptation of direct supertypes recursed infinitely on raw recursive types. eisop#2255 stopped viewpoint adaptation from searching supertypes of an already-substituted type, so the framework's implementation now works for the Mutability Checker and the copied superclass tail can go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Original code repo: https://github.com/opprop/immutability
Some of commits are presented in: https://github.com/Ao-senXiong/immutability/tree/pico-cf-only
Merge with: eisop/jdk#106
As discussed before, I will try to move PICO here gradually. Hopefully adding test cases and Javadoc with more discussion as well.