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

[inspection] re-enable comparing unrelated types inspection for scala 3 #656

Draft
wants to merge 1 commit into
base: idea241.x
Choose a base branch
from

Conversation

disordered
Copy link
Contributor

Adds support for '--language:strictEquality' compiler flag and 'CanEqual' when running inspection on scala 3 code

@disordered
Copy link
Contributor Author

I need help to finish this PR.

testCanEqualIncompatibleCaseObjects fails because ScTypeElement.type() method results in failure for case object types. I'm not sure how else I can convert it to ScType.

These tests fail because I can't figure out how I can lookup imported given implicits:

  • testCanEqualImportedFromCompanion
  • testCanEqualImported
  • testCanEqualDerivedOnTrait - I assume this will result in auto import as well

Adds support for '--language:strictEquality' compiler flag and 'CanEqual' when running inspection on scala 3 code
@SrTobi
Copy link
Contributor

SrTobi commented Mar 27, 2024

Hi @disordered. Thanks for the PR. We discussed it today and you are absolutely right, that we are missing the multiversal equality at the moment. I have not completely looked into this, but we will probably activate the inspection only if strictEquality is not used. When strictEquality is used, we will do something in the Annotator to issue a real error, as errors are normally not the job of inspections.

Also we are currently pretty close to the next release, so I'll probably start working on this only in about two weeks. I'll keep you up to date.

@disordered
Copy link
Contributor Author

disordered commented Mar 27, 2024

Hi @disordered. Thanks for the PR. We discussed it today and you are absolutely right, that we are missing the multiversal equality at the moment. I have not completely looked into this, but we will probably activate the inspection only if strictEquality is not used. When strictEquality is used, we will do something in the Annotator to issue a real error, as errors are normally not the job of inspections.

Also we are currently pretty close to the next release, so I'll probably start working on this only in about two weeks. I'll keep you up to date.

EDIT: On second read, I think you meant that CanEqual inspection should not be performed at all, including when compiler is not in strictEquality mode. If that's the case, then there are still fixes in the PR for tests in Scala 3.

I have already covered that part. The inspection doesn't run when strictEquality is enabled and it is in scala 3, except if it is a primitive type or String (we could add other types later), since you can make scala compiler happy by declaring CanEqual[String, Int] but it is not possible to implement this, unless some reflection tricks are used. Well, technically inspection runs, but it does not inspect CanEqual declarations. When declaration is missing, IntelliJ already shows an error stating that types are not comparable.

I mentioned above what I think are the only things missing for this to go out. The failing tests are part of the PR already.

I also just realised, I did not include a test that checks with strictEquality enabled, but I also cannot find an example of how to configure a test run with specific compiler flags, so help there is needed as well.

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