@@ -38,6 +38,7 @@ import org.utbot.framework.plugin.api.util.defaultValueModel
38
38
import org.utbot.framework.plugin.api.util.executableId
39
39
import org.utbot.framework.plugin.api.util.jClass
40
40
import org.utbot.framework.util.nextModelName
41
+ import java.lang.reflect.Constructor
41
42
import java.util.IdentityHashMap
42
43
43
44
/* *
@@ -256,7 +257,7 @@ class AssembleModelGenerator(private val methodUnderTest: UtMethod<*>) {
256
257
}
257
258
// fill field value if it hasn't been filled by constructor, and it is not default
258
259
if (fieldId in constructorInfo.affectedFields ||
259
- (fieldId !in constructorInfo.setFields && ! fieldModel.hasDefaultValue())
260
+ (fieldId !in constructorInfo.setFields && ! fieldModel.hasDefaultValue())
260
261
) {
261
262
val modifierCall = modifierCall(this , fieldId, assembleModel(fieldModel))
262
263
callChain.add(modifierCall)
@@ -357,15 +358,21 @@ class AssembleModelGenerator(private val methodUnderTest: UtMethod<*>) {
357
358
*/
358
359
private fun findBestConstructorOrNull (compositeModel : UtCompositeModel ): ConstructorId ? {
359
360
val classId = compositeModel.classId
360
- if (! classId.isPublic || classId.isInner) return null
361
+ if (! classId.isVisible || classId.isInner) return null
361
362
362
363
return classId.jClass.declaredConstructors
363
- .filter { it.isPublic || ! it.isPrivate && it.declaringClass.packageName.startsWith(methodPackageName) }
364
+ .filter { it.isVisible }
364
365
.sortedByDescending { it.parameterCount }
365
366
.map { it.executableId }
366
367
.firstOrNull { constructorAnalyzer.isAppropriate(it) }
367
368
}
368
369
370
+ private val ClassId .isVisible : Boolean
371
+ get() = this .isPublic || ! this .isPrivate && this .packageName.startsWith(methodPackageName)
372
+
373
+ private val Constructor <* >.isVisible : Boolean
374
+ get() = this .isPublic || ! this .isPrivate && this .declaringClass.packageName.startsWith(methodPackageName)
375
+
369
376
/* *
370
377
* Creates setter or direct setter call to set a field.
371
378
*
0 commit comments