{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3846","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3846/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3846/comments","events_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3846/events","html_url":"https://github.com/HaxeFoundation/haxe/issues/3846","id":57048348,"number":3846,"title":"extern + inline + @:overload: method not inlined","user":{"login":"clemos","id":32961,"avatar_url":"https://avatars.githubusercontent.com/u/32961?v=3","gravatar_id":"","url":"https://api.github.com/users/clemos","html_url":"https://github.com/clemos","followers_url":"https://api.github.com/users/clemos/followers","following_url":"https://api.github.com/users/clemos/following{/other_user}","gists_url":"https://api.github.com/users/clemos/gists{/gist_id}","starred_url":"https://api.github.com/users/clemos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clemos/subscriptions","organizations_url":"https://api.github.com/users/clemos/orgs","repos_url":"https://api.github.com/users/clemos/repos","events_url":"https://api.github.com/users/clemos/events{/privacy}","received_events_url":"https://api.github.com/users/clemos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-09T15:52:00Z","updated_at":"2015-02-14T10:36:20Z","closed_at":null,"body":"Consider the following code : \r\n```haxe\r\nclass Extern {\r\n\t@:overload( function (a:Int) : Void {})\r\n\tinline public static function test(a:String):Void {\r\n\t\treturn untyped Extern['my-test'](a);\r\n\t}\r\n}\r\n\r\nclass RegressionTest {\r\n\tstatic function main(){\r\n\t\tExtern.test(\"coucou\");\r\n\t\tExtern.test(1);\r\n\t}\r\n}\r\n```\r\nOn latest haxe/development, it will generate this js code:\r\n```js\r\nRegressionTest.main = function() {\r\n\tExtern[\"my-test\"](\"coucou\");\r\n\tExtern.test(1);\r\n};\r\n```\r\n\r\nAs you can see the second call, which correspond to the overloaded signature, won't be inlined.\r\n\r\nI use this trick a lot to workaround JS using invalid identifiers in Haxe.\r\nIt seems it used to work with previous versions (3.1.3), so it's likely a regression.\r\n\r\nAs a side note, it might be interresting to allow function bodies in `@:overload` in this situation: \r\nIt would allow to \"translate\" different signatures into different calls, including cases where the number of arguments matter.\r\nOf course in JS we can always use `apply/arguments` to forward calls, but it's not ideal."},"comment":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/comments/74370082","html_url":"https://github.com/HaxeFoundation/haxe/issues/3846#issuecomment-74370082","issue_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/3846","id":74370082,"user":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"created_at":"2015-02-14T10:36:20Z","updated_at":"2015-02-14T10:36:20Z","body":"@waneck: Are the overloaded fields supposed to have a `cf_expr` or not? We create them before following the original `cf_type` which means the TLazy is not called in time and the created copy ends up with `cf_expr = None`, which then cancels inlining."}}