{"action":"created","issue":{"url":"https://api.github.com/repos/google/j2objc/issues/776","repository_url":"https://api.github.com/repos/google/j2objc","labels_url":"https://api.github.com/repos/google/j2objc/issues/776/labels{/name}","comments_url":"https://api.github.com/repos/google/j2objc/issues/776/comments","events_url":"https://api.github.com/repos/google/j2objc/issues/776/events","html_url":"https://github.com/google/j2objc/issues/776","id":169178186,"number":776,"title":"ARC forbids ... when using lambdas","user":{"login":"L6Echo","id":14105998,"avatar_url":"https://avatars.githubusercontent.com/u/14105998?v=3","gravatar_id":"","url":"https://api.github.com/users/L6Echo","html_url":"https://github.com/L6Echo","followers_url":"https://api.github.com/users/L6Echo/followers","following_url":"https://api.github.com/users/L6Echo/following{/other_user}","gists_url":"https://api.github.com/users/L6Echo/gists{/gist_id}","starred_url":"https://api.github.com/users/L6Echo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/L6Echo/subscriptions","organizations_url":"https://api.github.com/users/L6Echo/orgs","repos_url":"https://api.github.com/users/L6Echo/repos","events_url":"https://api.github.com/users/L6Echo/events{/privacy}","received_events_url":"https://api.github.com/users/L6Echo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-03T16:43:35Z","updated_at":"2016-09-19T13:12:04Z","closed_at":"2016-09-19T13:12:03Z","body":"I upgraded today our project with many lambda-expressions from j2objc 1.0.1 to 1.1. \r\n\r\nThe java code get transpiled with \"-use-arc\" flag and the whole project is compiled with ARC. When compiling it fails with many \"ARC forbids ...\" errors\r\n\r\nEnvironment:\r\nXcode 7.2.1 (Tested also with Xcode 7.3.1)\r\niOS 9.2\r\n\r\n```\r\npublic interface Func1<T1, TRes, TException extends Exception> {\r\n\tTRes invoke(T1 arg1) throws TException;\r\n}\r\n```\r\n\r\n```\r\npublic class TestClass {\r\n\tpublic void test(){\r\n\t\tString test = \"Hello World\";\r\n\t\tFunc1<String,String,Exception> fn = arg1 -> test;\r\n\t\tLog.d(\"Test\", \"test: \"+test);\r\n\t}\r\n}\r\n```\r\n\r\ntranspiles to:\r\n```\r\n...\r\ntypedef struct TestClass$$Lambda$1_captures {\r\n  NSString * test;   //<----- ARC forbids Objective-C objects in struct\r\n} TestClass$$Lambda$1_captures;\r\n...\r\nid<NetTpkyMcUtilsFunc1> TestClass$$Lambda$1_get(NSString *test) {\r\n  static dispatch_once_t token;\r\n  static Class cls;\r\n  dispatch_once(&token, ^{\r\n    struct objc_method_description desc1 = protocol_getMethodDescription(@protocol(NetTpkyMcUtilsFunc1), @selector(invokeWithId:), YES, YES);\r\n\r\n    cls = CreatePossiblyCapturingClass(\r\n    \"TestClass$$Lambda$1\", 1, (Protocol *[]){ @protocol(NetTpkyMcUtilsFunc1)},\r\n    // ^-- 'CreatePossiblyCapturingClass' is unavailable: this system declaration uses an unsupported type\r\n    2,\r\n    (SEL []){ @selector(invokeWithId:), @selector(dealloc)},\r\n     // ^- ARC forbids use of 'dealloc' in a @selector\r\n     // ^-- ARC forbids use of 'dealloc' in a @selector\r\n     // ^-- Passing 'Protocol **' to parameter of type 'Protocol *__unsafe_unretained *' changes retain/release properties of pointer\r\n    (IMP []){ (IMP)&TestClass$$Lambda$1_impl, (IMP)&TestClass$$Lambda$1_dealloc},\r\n    (const char *[]){ desc1.types, \"v@:\"});\r\n  });\r\n\r\n  LambdaBase<NetTpkyMcUtilsFunc1> *result = NSAllocateObject(cls, sizeof(TestClass$$Lambda$1_captures), nil);\r\n    // ^-- 'autorelease' is unavailable: not available in automatic reference counting mode\r\n    // ^-- 'NSAllocateObject' is unavailable: not available in automatic reference counting mode\r\n\r\nTestClass$$Lambda$1_captures *captures = (TestClass$$Lambda$1_captures *) &result->captures_;\r\n  JreStrongAssign(&captures->test, test);\r\n  return [result autorelease];\r\n  // --- ARC forbids explicit message send of 'autorelease'\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/google/j2objc/issues/comments/247988843","html_url":"https://github.com/google/j2objc/issues/776#issuecomment-247988843","issue_url":"https://api.github.com/repos/google/j2objc/issues/776","id":247988843,"user":{"login":"kstanger","id":6548109,"avatar_url":"https://avatars.githubusercontent.com/u/6548109?v=3","gravatar_id":"","url":"https://api.github.com/users/kstanger","html_url":"https://github.com/kstanger","followers_url":"https://api.github.com/users/kstanger/followers","following_url":"https://api.github.com/users/kstanger/following{/other_user}","gists_url":"https://api.github.com/users/kstanger/gists{/gist_id}","starred_url":"https://api.github.com/users/kstanger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kstanger/subscriptions","organizations_url":"https://api.github.com/users/kstanger/orgs","repos_url":"https://api.github.com/users/kstanger/repos","events_url":"https://api.github.com/users/kstanger/events{/privacy}","received_events_url":"https://api.github.com/users/kstanger/received_events","type":"User","site_admin":false},"created_at":"2016-09-19T13:12:03Z","updated_at":"2016-09-19T13:12:03Z","body":"Fixed in [current source](https://github.com/google/j2objc/commit/773939392ee4a5f1e6d7820490a54cbcdd5f4cdf)."}}
{"actor":{"display_login":"kstanger"}}