File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ import org.utbot.framework.plugin.api.util.doubleStreamClassId
151151import org.utbot.framework.plugin.api.util.doubleStreamToArrayMethodId
152152import org.utbot.framework.plugin.api.util.intStreamClassId
153153import org.utbot.framework.plugin.api.util.intStreamToArrayMethodId
154+ import org.utbot.framework.plugin.api.util.isPackagePrivate
154155import org.utbot.framework.plugin.api.util.isSubtypeOf
155156import org.utbot.framework.plugin.api.util.longStreamClassId
156157import org.utbot.framework.plugin.api.util.longStreamToArrayMethodId
@@ -1112,7 +1113,11 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
11121113 private fun FieldId.getAccessExpression (variable : CgVariable ): CgExpression =
11131114 // Can directly access field only if it is declared in variable class (or in its ancestors)
11141115 // and is accessible from current package
1115- if (variable.type.hasField(this ) && canBeReadFrom(context)) {
1116+ if (variable.type.hasField(this )
1117+ // TODO: think about moving variable type checks into [isAccessibleFrom] after contest
1118+ && (! isPackagePrivate || variable.type.packageName == context.testClassPackageName)
1119+ && canBeReadFrom(context)
1120+ ) {
11161121 if (jField.isStatic) CgStaticFieldAccess (this ) else CgFieldAccess (variable, this )
11171122 } else {
11181123 utilsClassId[getFieldValue](variable, this .declaringClass.name, this .name)
You can’t perform that action at this time.
0 commit comments