{"action":"opened","issue":{"url":"https://api.github.com/repos/gradle/gradle-script-kotlin/issues/8","repository_url":"https://api.github.com/repos/gradle/gradle-script-kotlin","labels_url":"https://api.github.com/repos/gradle/gradle-script-kotlin/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/gradle/gradle-script-kotlin/issues/8/comments","events_url":"https://api.github.com/repos/gradle/gradle-script-kotlin/issues/8/events","html_url":"https://github.com/gradle/gradle-script-kotlin/issues/8","id":157274450,"number":8,"title":"Methods in the DSL that have Object overloads are problematic","user":{"login":"DanielThomas","id":1479220,"avatar_url":"https://avatars.githubusercontent.com/u/1479220?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielThomas","html_url":"https://github.com/DanielThomas","followers_url":"https://api.github.com/users/DanielThomas/followers","following_url":"https://api.github.com/users/DanielThomas/following{/other_user}","gists_url":"https://api.github.com/users/DanielThomas/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielThomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielThomas/subscriptions","organizations_url":"https://api.github.com/users/DanielThomas/orgs","repos_url":"https://api.github.com/users/DanielThomas/repos","events_url":"https://api.github.com/users/DanielThomas/events{/privacy}","received_events_url":"https://api.github.com/users/DanielThomas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-27T19:21:29Z","updated_at":"2016-05-27T19:21:29Z","closed_at":null,"body":"Methods in the DSL that have Object overloads are problematic. Kotlin selects the least specific signature https://youtrack.jetbrains.com/issue/KT-11128. For example, this code will call `all(Object)`:\r\n\r\n```\r\nconfigurations.getByName(\"compile\").resolutionStrategy.componentSelection.all { action ->\r\n}\r\n```\r\n\r\nHinting that the generic type doesn't help, this still selects `ComponentSelectionRules.all(Object)` and will fail at runtime:\r\n```\r\ncomponentSelection.all { action: ComponentSelection ->\r\n}\r\n\r\n```\r\n\r\nSo instead, you have to be a little more heavy handed and implement the Action:\r\n```\r\ncomponentSelection.all(Action<ComponentSelection> { selection ->\r\n})\r\n```\r\n\r\nThe extension I suggest in #7 would help in this case. Hopefully this is fixed to select the _most_ specific overload in Kotlin 1.1.0, but something to watch for."}}
{"actor":{"display_login":"DanielThomas"}}