[Bug]: CtRecordComponent::toField
adds new fields to the model with broken parents
#5265
Labels
CtRecordComponent::toField
adds new fields to the model with broken parents
#5265
Describe the bug
My code queries the
CtModel
for certain references and then tries to find the first common parent between all references. For this to work, it requires that allCtReference
s have at least the same root (should be the unnamed module). I assumed this is always the case, but the code below has two references for which this is not the case.The call to
CtRecordComponent::toField
seems to be the main problem, without this call or by setting the parent explicitly (ctField.setParent(ctRecord)
) the code works as expected. It is surprising to me that thetoField
call has side-effects on the model.Source code you are trying to analyze/transform
Source code for your Spoon processing
Actual output
Expected output
Spoon Version
10.3.0
JVM Version
openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment Temurin-17.0.1+12 (build 17.0.1+12) OpenJDK 64-Bit Server VM Temurin-17.0.1+12 (build 17.0.1+12, mixed mode, sharing)
What operating system are you using?
Windows 10
The text was updated successfully, but these errors were encountered: