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

Make CompatibilityBEI2.java pass. #8

Merged
merged 1 commit into from
Aug 18, 2019

Conversation

xingweitian
Copy link
Contributor

This PR makes CompatibilityBEI2.java pass.

Here is my thinking:

In @Immutable interface ImmutableInterface, after the viewpoint adaption, the type of Object is @Immutable.
So, <@Mutable Object> is incorrect (@Mutable is not a subtype of @Immutable).

Similarly, <@ReceiverDependantMutable Object> is incorrect (@RDM is not a subtype of @Immutable).

@wmdietl
Copy link
Member

wmdietl commented Aug 17, 2019

For the interface

@Immutable interface ImmutableInterface<E extends @ReceiverDependantMutable Object> {}

are the only valid type arguments @Immutable?

Can we easily add an error on the declaration of E's bound that the @ReceiverDependantMutable is misleading and that @Immutable must be used instead?

Copy link
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.

Your argument makes sense to me.

@xingweitian
Copy link
Contributor Author

For the interface

@Immutable interface ImmutableInterface<E extends @ReceiverDependantMutable Object> {}

are the only valid type arguments @Immutable?

Can we easily add an error on the declaration of E's bound that the @ReceiverDependantMutable is misleading and that @Immutable must be used instead?

For

@Immutable interface ImmutableInterface<E extends @ReceiverDependantMutable Object> {}

the valid type can also be @Mutable, that is to say, if we have

@Immutable interface ImmutableInterface<E extends @Mutable Object> {}

after the viewpoint adaption, the type of Object will not be changed.

@wmdietl
Copy link
Member

wmdietl commented Aug 18, 2019

For

@Immutable interface ImmutableInterface<E extends @ReceiverDependantMutable Object> {}

the valid type can also be @Mutable, that is to say, if we have

@Immutable interface ImmutableInterface<E extends @Mutable Object> {}

after the viewpoint adaption, the type of Object will not be changed.

You are changing the bound in the example.
Take the fixed interface:

@Immutable interface ImmutableInterface<E extends @ReceiverDependantMutable Object> {}

Which of the following are well-formed types:

ImmutableInterface<@Mutable String> a;
ImmutableInterface<@Immutable String> b;
ImmutableInterface<@Readonly String> c;
ImmutableInterface<@ReceiverDependableMutable String> d;

?

@xingweitian
Copy link
Contributor Author

For

@Immutable interface ImmutableInterface<E extends @ReceiverDependantMutable Object> {}

the valid type can also be @Mutable, that is to say, if we have

@Immutable interface ImmutableInterface<E extends @Mutable Object> {}

after the viewpoint adaption, the type of Object will not be changed.

You are changing the bound in the example.
Take the fixed interface:

@Immutable interface ImmutableInterface<E extends @ReceiverDependantMutable Object> {}

Which of the following are well-formed types:

ImmutableInterface<@Mutable String> a;
ImmutableInterface<@Immutable String> b;
ImmutableInterface<@Readonly String> c;
ImmutableInterface<@ReceiverDependableMutable String> d;

?

Sorry, I misunderstand before. For this fixed interface, only @Immutable is correct.

@wmdietl
Copy link
Member

wmdietl commented Aug 18, 2019

So when the checker sees

@Immutable interface ImmutableInterface<E extends @ReceiverDependantMutable Object> {}
@Mutable interface MutableInterface<E extends @ReceiverDependantMutable Object> {}

it would be convenient to suggest:

@Immutable interface ImmutableInterface<E extends @Immutable Object> {}
@Mutable interface MutableInterface<E extends @Mutable Object> {}

right? Maybe file this as a separate issue that you can look at sometime in the future.

@xingweitian
Copy link
Contributor Author

#9 was created for the further improvement , I will merge this PR for now.

@xingweitian xingweitian merged commit ab8af46 into opprop:adapt-to-cf-master Aug 18, 2019
@xingweitian xingweitian deleted the make-test-pass branch August 18, 2019 21:18
AndrewShf pushed a commit to AndrewShf/immutability that referenced this pull request Feb 10, 2022
…CompatibilityBEI2.java pass. (opprop#8)

Make CompatibilityBEI2.java pass.
Ao-senXiong added a commit to Ao-senXiong/immutability that referenced this pull request May 30, 2024
* adapt pico to CF and CFI master

* fix pico per changes in upstream CF and CFI

* remove incorrect aliasing and unnecessary method check

* remove wrong test diagnostic

* adapt to upstream changes

* fix extends and implements check

* tweak travis build script

* Remove useless separators.

* Unify the name of test files.

* Fix typo.

* Fix typo.

* Fix typo.

* Complete the messages.

* Use all dirs and jar file to fix the issue that "messages.properties" cannot be found. (#1)

* Tweaks.

* Use the correct error key.

* Fix typo (CompatabilityBEI2.java -> CompatibilityBEI2.java) and make CompatibilityBEI2.java pass. (opprop#8)

Make CompatibilityBEI2.java pass.

* Update.

* Update.

* api updates

* typo

* default-for annotator, default bottom on null, allow readonly as upper bound

* Implement super constructor call check.
Replace the error key "super.constructor.invocation.incompatible" with "super.invocation.invalid".
Tweaks test files to pass the test.

* Improve code and javadoc.

* clean debug messages and comment

* fixed HashCodeSafetyExample, addMissingAnnotations->replaceAnnotation

* fixed CompatibilityBEI2 + ReceiverTypeOutsideConstructor: pull default annotation for extends and implements clauses

* milestone: all typecheck tests passed

* add anno invalid check in local variables; add RDM extends/implements rules

* override cf default extends/implements checks

* fix anonymous type of new clause and test case
milestone: no INITIAL_TYPECHECK error in inference tests

* reuse test cases for typecheck and infer initial typecheck

* fix a accidentally disabled test case

* fix additional tests' errors

* test vpa over imp

* TODO: resolve path issues, remove this when fixed

* default class bound and super clause

* default class bound and super clause enhanced

* implicit immutable class bound + cast.unsafe

* remove wrong cast.unsafe keys

* bound of array fixed to READONLY. VPA not needed here because any type is permitted.
Note: how does PICO prevent changes on immutable arrays?

* bottom workaround + vpa interface

* enum default immutable. TODO: fix constructor check in mutable enum decl

* fix enum default in inference

* doc

* relocate common interface and annotator

* bound

* enum & super clause

* test case update

* tweaks on generic

* fix anno

* poly workaround

* update test cases (typecheck 100%, inference-init-tc 100%)

* API update: report

* API update: remove @DefaultInUncheckedCodeFor

* remove @spm

* Revert "remove @spm"

This reverts commit fe280a96

* @spm for static moved to new api

* exclude decl when checking static RDM (TC: 100%, INF: 6 fail)

* small tweaks

* tc cast.unsafe (TC: 100%, INF: 4 fail)

* inf-> workaround for anonymous class

* a small tweak

* update test cases (TC all pass)

* re-remove @spm

* add CF all-systems test

* small tweaks on test drivers

* interface

* isSubtype use native api

* infer atf + get bound

* tweaks

* checker.report update

* checker.report update

* tc

* tc

* ignore rdm on fields

* rdm field logic + tc

* VPA post check

* vpa post check

* field rdm default

* check anno

* tc update

* transitive (needs fix)

* class bound != PM

* receiver != BOTTOM

* stop assign immutable constant slot to enum usage. enum could be mutable

* PICO does not need existential slot on class decl anno

* use constant slot for explicit class decl anno

* update init bound extraction function

* update call to init bound extraction function

* prevent poly infer

* bound handling for anonymous class

* anonymous class method receiver workaround

* workarounds for anonymous class for getTypeOfExtendsImplements

* extract method

* do not apply real anno to atm during infer

* not apply immutable constant to enum during infer-typecheck

* add init bound extraction function

* update tc

* array bound -> RDM (TC)

* exclude static inner class decl from static scope

* don't check with default during inference

* add immutable alias for real type factory

* array decl method

* implicit shallow immutable warning (TC)

* tune up vpa

* better logic to check anonymous

* enum heck

* enforce check without refinement

* workaround for implicit lib type param

* disable alias

* workaround: vpa decl w/o anno

* consistency infer and tc

* ext and imp clause logic

* override base ext/imp clause check

* override base check on ext/imp clauses

* anonymous class logic

* receiver cannot infer to poly

* allow explicit poly on receiver

* class bound for infer

* allow factory to get class decl slot

* annotator: handle decl bound

* annotator: skip null

* annotator: replace real anno

* annotator: not infer to poly

* annotator: drop super decl constraints

* visitor: skip uses w/o slot

* rdm-field: field uses be both rdm or mutable

* comments

* notes

* tweaks

* stubs

* reim test cases

* glacier test cases

* temp ignore all systems test

* stub path problem

* +useOptimisticUncheckedDefaults

* import issue

* import issue

* update pico, fix CF api rename, update gradle version

* commits for fixing PICO-TypeCheck and part of PICO-Infer

* resolve new array problems

* add inference component back to gradle test

* E on line 5 extends readonly, but the declared on line 3 extends immutable

* use valueof static method

* use smaller case local variable

* add imports to the testfile

* change implicit.shallow.immutable from warning to error

* make the testcase more clear

* Clarify the purpose of the junit test; make default annotations explicitly for one junit test

* refactor and fix bugs causing test failures

* fix typecheck error

* Adapt PICO to opprop

* Delete glacier and reminfer test for merge

* Delete reminfer test for merge

* Add HoldsForDefaultValue for quals

* Delete old PICO files

* Add new line at the end of files

* Fix compile test errors

* Delete reim and glacier related tests

* Add error to test case

* Handle initialization block

* Add a new line at the end of file

* Update build.gradle

* Wrap up type check

* Add a new line at the end

* Further clean up the code

* Simplify the code

* Further clean up

* New line at the end

---------

Co-authored-by: Baorui Zhou <b42zhou@uwaterloo.ca>
Co-authored-by: xingweitian <13183370+xingweitian@users.noreply.github.com>
Co-authored-by: Werner Dietl <wdietl@gmail.com>
Co-authored-by: xingweitian <xingweitian@gmail.com>
Co-authored-by: lnsun <lnsun@noreply.github.com>
Co-authored-by: lnsun <57457122+lnsun@users.noreply.github.com>
Co-authored-by: Haifeng Shi <h223shi@uwaterloo.ca>
Co-authored-by: Haifeng Shi <shihaifeng1998@gmail.com>
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