Skip to content

Fix unnecessary reflection calls in the generated code - #1491

Merged
EgorkaKulikov merged 1 commit into
mainfrom
andrey-t/unnecessary-reflection-calls
Dec 7, 2022
Merged

Fix unnecessary reflection calls in the generated code#1491
EgorkaKulikov merged 1 commit into
mainfrom
andrey-t/unnecessary-reflection-calls

Conversation

@sofurihafe

Copy link
Copy Markdown
Member

Description

This PR fixes unnecessary reflection calls as described in the following issue and infinite loop in self-reference initialization (there are examples in the manual testing section).

Fixes # (1353)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Automated Testing

UTBot-samples.

Manual Scenario

Tested on the code attached in the issue. Additionally, tested self-reference cases like the following:

// First scenarioclassFirstClass {
SecondClasssecondClass;
FirstClass(SecondClasssecond) {
this.secondClass = second;
}
}
classSecondClass {
FirstClassfirstClass;
SecondClass(FirstClassfirst) {
this.firstClass = first;
}
}
classClassWithCrossReferenceRelationship {
publicFirstClassreturnFirstClass(intvalue) {
if (value == 0) {
returnnewFirstClass(newSecondClass(null));
} else {
FirstClassfirst = newFirstClass(null);
first.secondClass = newSecondClass(first);
returnfirst;
}
}
}
// Second scenarioclassFirstClass1 {
ThirdClass1thirdClass;
FirstClass1(ThirdClass1third) {
this.thirdClass = third;
}
}
classSecondClass1 {
FirstClass1firstClass;
SecondClass1(FirstClass1first) {
this.firstClass = first;
}
}
classThirdClass1 {
SecondClass1secondClass;
ThirdClass1(SecondClass1second) {
this.secondClass = second;
}
}
classClassWithCrossReferenceRelationship1 {
publicFirstClass1returnFirstClass(intvalue) {
FirstClass1first = newFirstClass1(null);
SecondClass1second = newSecondClass1(first);
ThirdClass1third = newThirdClass1(second);
first.thirdClass = third;
returnfirst;
}
}

@sofurihafe
sofurihafeforce-pushed the andrey-t/unnecessary-reflection-calls branch from 1f99a2c to de865a5CompareDecember 7, 2022 20:05
@EgorkaKulikov
EgorkaKulikov merged commit e1dd1d1 into mainDec 7, 2022
@EgorkaKulikov
EgorkaKulikov deleted the andrey-t/unnecessary-reflection-calls branch December 7, 2022 20:40
@EgorkaKulikovEgorkaKulikov linked an issue Dec 9, 2022 that may be closed by this pull request
Sign up for freeto 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.

Unnecessary reflection when one constructor is used more than once

2 participants

@sofurihafe@EgorkaKulikov