Skip to content

Move PICO to EISOP#1013

Open
aosen-xiong wants to merge 84 commits intoeisop:masterfrom
aosen-xiong:pico-move
Open

Move PICO to EISOP#1013
aosen-xiong wants to merge 84 commits intoeisop:masterfrom
aosen-xiong:pico-move

Conversation

@aosen-xiong
Copy link
Copy Markdown
Collaborator

@aosen-xiong aosen-xiong commented Dec 9, 2024

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.

Co-authored-by: Werner Dietl <wdietl@gmail.com>
Co-authored-by: Haifeng Shi <shihaifeng1998@gmail.com>
Co-authored-by: Weitian Xing <xingweitian@gmail.com>
Co-authored-by: Jeff Luo <j36luo@uwaterloo.ca>
Co-authored-by: Mier Ta <m2ta@uwaterloo.ca>
Copy link
Copy Markdown
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

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

A quick round of initial comments.

PICOViewpointAdapter vpa = atypeFactory.getViewpointAdapter();
AnnotationMirror adapted = vpa.combineAnnotationWithAnnotation(lhs, rhs);
return atypeFactory.getQualifierHierarchy().isSubtypeQualifiersOnly(adapted, lhs);
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

After #1032, this method and the override of isValidUse( AnnotatedDeclaredType declarationType, AnnotatedDeclaredType useType, Tree tree) can be removed.

@aosen-xiong
Copy link
Copy Markdown
Collaborator Author

aosen-xiong commented Jan 11, 2025

Looks like this hack override of checkoverride I removed in 38a547a also indicates a bug in the framework StructuralEqualityComparer. Upstream has similar 6867.

I am using a different branch for doing case study on guava based on the hack.

Comment on lines +515 to +538
protected boolean isTypeCastSafe(AnnotatedTypeMirror castType, AnnotatedTypeMirror exprType) {
QualifierHierarchy qualifierHierarchy = atypeFactory.getQualifierHierarchy();

final TypeKind castTypeKind = castType.getKind();
if (castTypeKind == TypeKind.DECLARED) {
// Don't issue an error if the mutability annotations are equivalent to the qualifier
// upper bound of the type.
// BaseTypeVisitor#isTypeCastSafe is not used, to be consistent with inference which
// only have mutability qualifiers if inference is supporting FBC in the future, this
// overridden method can be removed.
AnnotatedDeclaredType castDeclared = (AnnotatedDeclaredType) castType;
AnnotationMirror bound =
qualifierHierarchy.findAnnotationInHierarchy(
atypeFactory.getTypeDeclarationBounds(castDeclared.getUnderlyingType()),
atypeFactory.READONLY);
assert bound != null;

if (AnnotationUtils.areSame(
castDeclared.getAnnotationInHierarchy(atypeFactory.READONLY), bound)) {
return true;
}
}

return super.isTypeCastSafe(castType, exprType);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This should be nicer after #1049

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