Cannot access internal constructor from unit test when adding Dagger 2 as dependency


Let say we have a kotlin class defined as:

package foo
class Bar internal constructor() {

When I try to init that object from a test method like:

package foo
class BarTest {
    fun testingBar() {
        Bar()  //<----- error

I get a following error:
Cannot access '<init>': it is internal in 'Bar'

Both Bar and BarTest are in the same AndroidStudio module (android library) Both paths to sources were defined in a gradle:

sourceSets { += 'src/main/kotlin' += 'src/test/kotlin'

I’m using
ext.kotlin_version = '1.1.3-2'

I’ve tried to find the cause and it turns out that when I remove dagger 2 dependency the problem goes away.

//dagger 2
implementation ''
kapt '' //<---- this is causing errors

In this sample project dagger isn’t used anywhere. Just adding dependency to gradle causes accessing classes with internal constructor impossible.