Skip to content

Support anonymous classes #760

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

Merged
merged 3 commits into from
Sep 15, 2022
Merged

Support anonymous classes #760

merged 3 commits into from
Sep 15, 2022

Conversation

ArsenHD
Copy link
Collaborator

@ArsenHD ArsenHD commented Aug 22, 2022

Description

This PR removes filters that prevented anonymous classes from being used. It also allows code generation to work with anonymous class instances. Not via reflection, but rather by storing these instances in variables of the anonymous class supertype. For example, instance of anonymous class implementing interface Predicate will be stored in a variable of type Predicate. If we have to access any fields of methods declared in anonymous class, it will be done through reflection, but all members of the supertype will be accessed directly.

This PR partly fixes issue #617. Now tests are generated, but there seems to be some problem with accessing enum constants that have corresponding anonymous classes, to be discussed.

Type of Change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Automated Testing

org.utbot.examples.objects.AnonymousClassesExampleTest

Manual Scenario

Change was tested manually on example of code from issue #617. Tests are generated, but as said in the description, they are yet not fully correct. The exact problem is unclear. To be discussed.

Checklist (remove irrelevant options):

This is the author self-check list

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • New tests have been added
  • All tests pass locally with my changes

@ArsenHD ArsenHD requested a review from Damtev August 22, 2022 13:15
@ArsenHD ArsenHD force-pushed the ArsenHD/support-anonymous-classes branch from 6f2b1a9 to b65f7f8 Compare August 22, 2022 21:37
Copy link
Member

@Damtev Damtev left a comment

Choose a reason for hiding this comment

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

Could you please add some new tests (for example, with an anonymous class as a method result)?

@ArsenHD ArsenHD force-pushed the ArsenHD/support-anonymous-classes branch 3 times, most recently from 01363ff to 0b0b0c3 Compare September 1, 2022 09:45
@ArsenHD
Copy link
Collaborator Author

ArsenHD commented Sep 1, 2022

Could you please add some new tests (for example, with an anonymous class as a method result)?

We already had tests on this. I updated them according to my changes.

@ArsenHD ArsenHD force-pushed the ArsenHD/support-anonymous-classes branch from 0b0b0c3 to 35cb975 Compare September 5, 2022 14:06
@ArsenHD ArsenHD force-pushed the ArsenHD/support-anonymous-classes branch from 35cb975 to da1997a Compare September 15, 2022 12:16
@ArsenHD ArsenHD merged commit 75a8ccf into main Sep 15, 2022
@ArsenHD ArsenHD deleted the ArsenHD/support-anonymous-classes branch September 15, 2022 13:13
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