{"action":"created","issue":{"url":"https://api.github.com/repos/munificent/wren/issues/250","labels_url":"https://api.github.com/repos/munificent/wren/issues/250/labels{/name}","comments_url":"https://api.github.com/repos/munificent/wren/issues/250/comments","events_url":"https://api.github.com/repos/munificent/wren/issues/250/events","html_url":"https://github.com/munificent/wren/issues/250","id":65791315,"number":250,"title":"Call super constructor","user":{"login":"ComFreek","id":1827709,"avatar_url":"https://avatars.githubusercontent.com/u/1827709?v=3","gravatar_id":"","url":"https://api.github.com/users/ComFreek","html_url":"https://github.com/ComFreek","followers_url":"https://api.github.com/users/ComFreek/followers","following_url":"https://api.github.com/users/ComFreek/following{/other_user}","gists_url":"https://api.github.com/users/ComFreek/gists{/gist_id}","starred_url":"https://api.github.com/users/ComFreek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ComFreek/subscriptions","organizations_url":"https://api.github.com/users/ComFreek/orgs","repos_url":"https://api.github.com/users/ComFreek/repos","events_url":"https://api.github.com/users/ComFreek/events{/privacy}","received_events_url":"https://api.github.com/users/ComFreek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"munificent","id":46275,"avatar_url":"https://avatars.githubusercontent.com/u/46275?v=3","gravatar_id":"","url":"https://api.github.com/users/munificent","html_url":"https://github.com/munificent","followers_url":"https://api.github.com/users/munificent/followers","following_url":"https://api.github.com/users/munificent/following{/other_user}","gists_url":"https://api.github.com/users/munificent/gists{/gist_id}","starred_url":"https://api.github.com/users/munificent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munificent/subscriptions","organizations_url":"https://api.github.com/users/munificent/orgs","repos_url":"https://api.github.com/users/munificent/repos","events_url":"https://api.github.com/users/munificent/events{/privacy}","received_events_url":"https://api.github.com/users/munificent/received_events","type":"User","site_admin":false},"milestone":null,"comments":15,"created_at":"2015-04-01T22:17:42Z","updated_at":"2015-04-06T14:45:07Z","closed_at":null,"body":"How can I call a super constructor?\r\n\r\n```\r\nclass A {\r\n  new {\r\n    IO.print(\"A's constructor\")\r\n  }\r\n}\r\n\r\nclass B is A {\r\n  new {\r\n    IO.print(\"B's constructor\")\r\n  }\r\n}\r\n\r\nnew B\r\n```\r\nThe above code will only output *B's constructor'. I've already tried adding `super.new` in B's constructor to no avail. It seems that this feature is not implemented yet.\r\n"},"comment":{"url":"https://api.github.com/repos/munificent/wren/issues/comments/90084414","html_url":"https://github.com/munificent/wren/issues/250#issuecomment-90084414","issue_url":"https://api.github.com/repos/munificent/wren/issues/250","id":90084414,"user":{"login":"munificent","id":46275,"avatar_url":"https://avatars.githubusercontent.com/u/46275?v=3","gravatar_id":"","url":"https://api.github.com/users/munificent","html_url":"https://github.com/munificent","followers_url":"https://api.github.com/users/munificent/followers","following_url":"https://api.github.com/users/munificent/following{/other_user}","gists_url":"https://api.github.com/users/munificent/gists{/gist_id}","starred_url":"https://api.github.com/users/munificent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munificent/subscriptions","organizations_url":"https://api.github.com/users/munificent/orgs","repos_url":"https://api.github.com/users/munificent/repos","events_url":"https://api.github.com/users/munificent/events{/privacy}","received_events_url":"https://api.github.com/users/munificent/received_events","type":"User","site_admin":false},"created_at":"2015-04-06T14:45:07Z","updated_at":"2015-04-06T14:45:07Z","body":"Right. The problem is that Wren currently dispatches `super` calls by looking up the method on the superclass of the *receiver*. In cases where the method is inherited, that's wrong. It should be the superclass of *the class where the method was defined*.\r\n\r\nIn your example, the execution looks like:\r\n\r\n```\r\n(new C).method() // Looks up receiver's class: C.\r\nsuper.method() in C's method // Look's up receiver's superclass: B.\r\nsuper.method() in B's method // Looks up receiver's superclass: B. WRONG!\r\n```\r\n\r\nOn the last line, it should be looking up the superclass of the class where `method()` is defined. In this case, we're talking about the method in `B`, so it should look up `A`.\r\n\r\nIn other words, superclass calls are always *statically dispatched to a fixed class*, and not at all based on the receiver's class."}}