@@ -194,18 +194,22 @@ internal class CgCallableAccessManagerImpl(val context: CgContext) : CgCallableA
194194 // method of the current test class can be called on its 'this' instance
195195 currentTestClass == executable.classId && this isThisInstanceOf currentTestClass -> true
196196
197- // method of a class can be called on an object of this class or any of its subtypes
197+ // method of the current test class can be called on an object of this class or any of its subtypes
198198 this .type isSubtypeOf executable.classId -> true
199199
200- // We allow callers with [stubberClassId] classId to call any executable.
201- // Example to see why: doNothing().when(entityManagerMock).persist(any()).
202- // Here [persist()] cannot be called on [doNothing().when(entityManagerMock)],
203- // because it requires [EntityManager] classId caller.
204- this .type == stubberClassId -> true
200+ // method of the current test class can be called on builtin type
201+ this .type in builtinCallersWithoutReflection -> true
205202
206203 else -> false
207204 }
208205
206+ // Fore some builtin types do not having [ClassId] we need to clarify
207+ // that it is allowed to call their methods without reflection.
208+ //
209+ // This approach is used, for example, to render the constructions with stubs
210+ // like `doNothing().when(entityManagerMock).persist(any())`.
211+ private val builtinCallersWithoutReflection = setOf<ClassId >(stubberClassId)
212+
209213 /* *
210214 * For Kotlin extension functions, real caller is one of the arguments in JVM method (and declaration class is omitted),
211215 * thus we should move it from arguments to caller
0 commit comments