{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon/issues/6685","repository_url":"https://api.github.com/repos/ceylon/ceylon","labels_url":"https://api.github.com/repos/ceylon/ceylon/issues/6685/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon/issues/6685/comments","events_url":"https://api.github.com/repos/ceylon/ceylon/issues/6685/events","html_url":"https://github.com/ceylon/ceylon/issues/6685","id":187693997,"number":6685,"title":"wildcard capture","user":{"login":"gavinking","id":579974,"avatar_url":"https://avatars.githubusercontent.com/u/579974?v=3","gravatar_id":"","url":"https://api.github.com/users/gavinking","html_url":"https://github.com/gavinking","followers_url":"https://api.github.com/users/gavinking/followers","following_url":"https://api.github.com/users/gavinking/following{/other_user}","gists_url":"https://api.github.com/users/gavinking/gists{/gist_id}","starred_url":"https://api.github.com/users/gavinking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavinking/subscriptions","organizations_url":"https://api.github.com/users/gavinking/orgs","repos_url":"https://api.github.com/users/gavinking/repos","events_url":"https://api.github.com/users/gavinking/events{/privacy}","received_events_url":"https://api.github.com/users/gavinking/received_events","type":"User","site_admin":false},"labels":[{"id":286511985,"url":"https://api.github.com/repos/ceylon/ceylon/labels/t-feature","name":"t-feature","color":"02e10c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ceylon/ceylon/milestones/6","html_url":"https://github.com/ceylon/ceylon/milestones/1.5","labels_url":"https://api.github.com/repos/ceylon/ceylon/milestones/6/labels","id":1411357,"number":6,"title":"1.5","description":null,"creator":{"login":"CeylonMigrationBot","id":6583436,"avatar_url":"https://avatars.githubusercontent.com/u/6583436?v=3","gravatar_id":"","url":"https://api.github.com/users/CeylonMigrationBot","html_url":"https://github.com/CeylonMigrationBot","followers_url":"https://api.github.com/users/CeylonMigrationBot/followers","following_url":"https://api.github.com/users/CeylonMigrationBot/following{/other_user}","gists_url":"https://api.github.com/users/CeylonMigrationBot/gists{/gist_id}","starred_url":"https://api.github.com/users/CeylonMigrationBot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CeylonMigrationBot/subscriptions","organizations_url":"https://api.github.com/users/CeylonMigrationBot/orgs","repos_url":"https://api.github.com/users/CeylonMigrationBot/repos","events_url":"https://api.github.com/users/CeylonMigrationBot/events{/privacy}","received_events_url":"https://api.github.com/users/CeylonMigrationBot/received_events","type":"User","site_admin":false},"open_issues":62,"closed_issues":5,"state":"open","created_at":"2015-11-14T01:13:20Z","updated_at":"2016-11-07T12:03:38Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-11-07T11:59:47Z","updated_at":"2016-11-14T18:10:42Z","closed_at":null,"body":"We're discussing wildcard capture for _Java functions_, which have erased type arguments in #6682. It turns out we can do it with model loader tricks.\r\n\r\nIn fact, the exact same transformation rules mentioned in #6682 are sound in Ceylon, since they specify that there must be _exactly one_ invariant occurrence of the type parameter in the value parameter list.\r\n\r\n> The covariant transformation, replacing all invariant occurrences of `T` with `out T`, is sound if:\r\n>\r\n> - `T` never occurs contravariantly in the return type, and\r\n> - `T` occurs exactly once, invariantly, in the parameter list.\r\n>\r\n> The contravariant transformation, replacing all invariant occurrences of `T` with `in T` is sound if:\r\n>\r\n> - `T` never occurs covariantly in the return type, and\r\n> - `T` occurs exactly once, invariantly, in the parameter list.\r\n\r\n_However_, this requires a change to the *runtime semantics* of Ceylon, since we could now have an invocation or instantiation where the type argument is wildcarded *at compile time*. In this case, the type argument has to be taken from the actual argument passed to the invariant occurrence of the type parameter.\r\n\r\nFor example, given:\r\n\r\n```ceylon\r\nMutableList<MutableEntry<T,T>> makePairs(MutableList<T> list) \r\n        => ArrayList { for (x in list) MutableEntry(x,x) };\r\n\r\nMutableList<out Object> list = ArrayList<String>();\r\nMutableList<MutableEntry<out Object, out Object>> pairs = makePairs(list);\r\n```\r\n\r\nThen the inferred type argument is `out Object`, a wildcarded argument, something we can't currently have. At runtime, the actual type argument is `String`, which must be extracted from the `list` _at runtime_.\r\n\r\nThat's not going to be _at all_ easy to implement, at least not in full generality!\r\n\r\nBut it's interesting to see that it's possible in principle.\r\n\r\nRelated issues: #5565, #6682."},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon/issues/comments/260413763","html_url":"https://github.com/ceylon/ceylon/issues/6685#issuecomment-260413763","issue_url":"https://api.github.com/repos/ceylon/ceylon/issues/6685","id":260413763,"user":{"login":"jvasileff","id":236050,"avatar_url":"https://avatars.githubusercontent.com/u/236050?v=3","gravatar_id":"","url":"https://api.github.com/users/jvasileff","html_url":"https://github.com/jvasileff","followers_url":"https://api.github.com/users/jvasileff/followers","following_url":"https://api.github.com/users/jvasileff/following{/other_user}","gists_url":"https://api.github.com/users/jvasileff/gists{/gist_id}","starred_url":"https://api.github.com/users/jvasileff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvasileff/subscriptions","organizations_url":"https://api.github.com/users/jvasileff/orgs","repos_url":"https://api.github.com/users/jvasileff/repos","events_url":"https://api.github.com/users/jvasileff/events{/privacy}","received_events_url":"https://api.github.com/users/jvasileff/received_events","type":"User","site_admin":false},"created_at":"2016-11-14T18:10:42Z","updated_at":"2016-11-14T18:10:42Z","body":"Since I happen to be looking at this, a few BC thoughts come to mind for the Java backend:\r\n\r\n1. Fields for TPs are currently `private` (would prob. need `public` getters)\r\n2. Interface companion classes aren't always generated, so TPs of interfaces aren't always readily available\r\n3. For 2), it may be best anyway to use `abstract` interface methods for TPs of interfaces (rather than fields in companion objects.) This would also provide the opportunity to make them lazy, if that would improve performance."}}
{"actor":{"display_login":"jvasileff"}}