{"action":"created","issue":{"url":"https://api.github.com/repos/nhaarman/mockito-kotlin/issues/310","repository_url":"https://api.github.com/repos/nhaarman/mockito-kotlin","labels_url":"https://api.github.com/repos/nhaarman/mockito-kotlin/issues/310/labels{/name}","comments_url":"https://api.github.com/repos/nhaarman/mockito-kotlin/issues/310/comments","events_url":"https://api.github.com/repos/nhaarman/mockito-kotlin/issues/310/events","html_url":"https://github.com/nhaarman/mockito-kotlin/issues/310","id":382891327,"node_id":"MDU6SXNzdWUzODI4OTEzMjc=","number":310,"title":"kotlin 1.3.20","user":{"login":"bohsen","id":355452,"node_id":"MDQ6VXNlcjM1NTQ1Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/355452?v=4","gravatar_id":"","url":"https://api.github.com/users/bohsen","html_url":"https://github.com/bohsen","followers_url":"https://api.github.com/users/bohsen/followers","following_url":"https://api.github.com/users/bohsen/following{/other_user}","gists_url":"https://api.github.com/users/bohsen/gists{/gist_id}","starred_url":"https://api.github.com/users/bohsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bohsen/subscriptions","organizations_url":"https://api.github.com/users/bohsen/orgs","repos_url":"https://api.github.com/users/bohsen/repos","events_url":"https://api.github.com/users/bohsen/events{/privacy}","received_events_url":"https://api.github.com/users/bohsen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-20T23:31:49Z","updated_at":"2018-11-21T07:54:04Z","closed_at":null,"author_association":"NONE","body":"[The \"quirk\" ](https://github.com/nhaarman/mockito-kotlin/blob/ec75b8aca66a872234aaec9a55ea34e62958c225/mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2/internal/CreateInstance.kt#L40)that mockito-kotlin is relying on to create mock instances is [targeted to be fixed in the upcoming 1.3.20 release of kotlin](https://youtrack.jetbrains.com/issue/KT-8135).\r\n\r\nWhat to do after that?"},"comment":{"url":"https://api.github.com/repos/nhaarman/mockito-kotlin/issues/comments/440569751","html_url":"https://github.com/nhaarman/mockito-kotlin/issues/310#issuecomment-440569751","issue_url":"https://api.github.com/repos/nhaarman/mockito-kotlin/issues/310","id":440569751,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDU2OTc1MQ==","user":{"login":"nhaarman","id":3015152,"node_id":"MDQ6VXNlcjMwMTUxNTI=","avatar_url":"https://avatars2.githubusercontent.com/u/3015152?v=4","gravatar_id":"","url":"https://api.github.com/users/nhaarman","html_url":"https://github.com/nhaarman","followers_url":"https://api.github.com/users/nhaarman/followers","following_url":"https://api.github.com/users/nhaarman/following{/other_user}","gists_url":"https://api.github.com/users/nhaarman/gists{/gist_id}","starred_url":"https://api.github.com/users/nhaarman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhaarman/subscriptions","organizations_url":"https://api.github.com/users/nhaarman/orgs","repos_url":"https://api.github.com/users/nhaarman/repos","events_url":"https://api.github.com/users/nhaarman/events{/privacy}","received_events_url":"https://api.github.com/users/nhaarman/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T07:54:04Z","updated_at":"2018-11-21T07:54:04Z","author_association":"OWNER","body":"Mockito-kotlin 1 used to do a lot of reflection-based instantiation to be able to deal with this, which made it rely on the reflect library. Using different versions of the stdlib and the reflection library leads to [conflict problems](https://github.com/nhaarman/mockito-kotlin/wiki/Conflict-with-dependency).  \r\n[KT-18398](https://youtrack.jetbrains.com/issue/KT-18398) talks about solving this issue which coincidentally is fixed for 1.3.20 as well.\r\n\r\nOther problems with this reflection-based instantiation is that it tried to use the 'easiest' constructor available, passing in dummy data when possible. When this instantiation would fail for example due to range checks, users could statically register 'instance creators'. Statically registering things may lead to flaky tests.\r\n\r\nSince then however, Mockito's `mock-maker-inline` came around, allowing final classes to be mocked. What was initially impossible now may be possible: \r\n\r\n```kotlin\r\ninline fun <reified T : Any> createInstance(): T {\r\n    return mock()\r\n}\r\n```\r\n\r\nAlthough.. [Can I `thenReturn()` an inlined `mock()`?](https://github.com/mockito/mockito/wiki/FAQ#can-i-thenreturn-an-inlined-mock-). \r\nThis would also mean that users need to have `mock-maker-inline` enabled; I'm not sure what the current stability status on that feature is."}}
{"actor":{"display_login":"nhaarman"}}