{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/3989","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3989/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3989/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3989/events","html_url":"https://github.com/crystal-lang/crystal/issues/3989","id":205049816,"number":3989,"title":"T.new finds #initialize of T's child when T is a parameter","user":{"login":"ezrast","id":6622843,"avatar_url":"https://avatars.githubusercontent.com/u/6622843?v=3","gravatar_id":"","url":"https://api.github.com/users/ezrast","html_url":"https://github.com/ezrast","followers_url":"https://api.github.com/users/ezrast/followers","following_url":"https://api.github.com/users/ezrast/following{/other_user}","gists_url":"https://api.github.com/users/ezrast/gists{/gist_id}","starred_url":"https://api.github.com/users/ezrast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezrast/subscriptions","organizations_url":"https://api.github.com/users/ezrast/orgs","repos_url":"https://api.github.com/users/ezrast/repos","events_url":"https://api.github.com/users/ezrast/events{/privacy}","received_events_url":"https://api.github.com/users/ezrast/received_events","type":"User","site_admin":false},"labels":[{"id":20487869,"url":"https://api.github.com/repos/crystal-lang/crystal/labels/kind:feature","name":"kind:feature","color":"84b6eb","default":false},{"id":260346906,"url":"https://api.github.com/repos/crystal-lang/crystal/labels/status:accepted","name":"status:accepted","color":"00B85C","default":false},{"id":253019637,"url":"https://api.github.com/repos/crystal-lang/crystal/labels/topic:compiler","name":"topic:compiler","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/crystal-lang/crystal/milestones/18","html_url":"https://github.com/crystal-lang/crystal/milestone/18","labels_url":"https://api.github.com/repos/crystal-lang/crystal/milestones/18/labels","id":2267807,"number":18,"title":"Next","description":"","creator":{"login":"bcardiff","id":459923,"avatar_url":"https://avatars.githubusercontent.com/u/459923?v=3","gravatar_id":"","url":"https://api.github.com/users/bcardiff","html_url":"https://github.com/bcardiff","followers_url":"https://api.github.com/users/bcardiff/followers","following_url":"https://api.github.com/users/bcardiff/following{/other_user}","gists_url":"https://api.github.com/users/bcardiff/gists{/gist_id}","starred_url":"https://api.github.com/users/bcardiff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcardiff/subscriptions","organizations_url":"https://api.github.com/users/bcardiff/orgs","repos_url":"https://api.github.com/users/bcardiff/repos","events_url":"https://api.github.com/users/bcardiff/events{/privacy}","received_events_url":"https://api.github.com/users/bcardiff/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":15,"state":"open","created_at":"2017-01-20T19:28:52Z","updated_at":"2017-02-09T10:49:00Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2017-02-03T01:39:11Z","updated_at":"2017-02-09T10:51:29Z","closed_at":null,"body":"This appears related to https://github.com/crystal-lang/crystal/issues/2665. Feel free to mark as dupe.\r\n\r\nThe compiler won't let me instantiate a parameter type whose child defines `#initialize` with different arguments:\r\n```crystal\r\nclass Base\r\nend\r\n\r\nclass Derived < Base\r\n  def initialize(x : Int32)\r\n  end\r\nend\r\n\r\nclass Generic(T)\r\n  def initialize\r\n    T.new\r\n  end\r\nend\r\n\r\nGeneric(Base).new\r\n```\r\nCompiler output is `wrong number of arguments for 'Derived#initialize' (given 0, expected 1)` even though `Derived#initialize` should never get called, unless there's a nuance to the type system I'm missing.\r\n```\r\n$  crystal --version\r\nCrystal 0.20.5 [ccf46c0] (2017-01-20)\r\n```"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/278608766","html_url":"https://github.com/crystal-lang/crystal/issues/3989#issuecomment-278608766","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3989","id":278608766,"user":{"login":"asterite","id":209371,"avatar_url":"https://avatars.githubusercontent.com/u/209371?v=3","gravatar_id":"","url":"https://api.github.com/users/asterite","html_url":"https://github.com/asterite","followers_url":"https://api.github.com/users/asterite/followers","following_url":"https://api.github.com/users/asterite/following{/other_user}","gists_url":"https://api.github.com/users/asterite/gists{/gist_id}","starred_url":"https://api.github.com/users/asterite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterite/subscriptions","organizations_url":"https://api.github.com/users/asterite/orgs","repos_url":"https://api.github.com/users/asterite/repos","events_url":"https://api.github.com/users/asterite/events{/privacy}","received_events_url":"https://api.github.com/users/asterite/received_events","type":"User","site_admin":false},"created_at":"2017-02-09T10:51:29Z","updated_at":"2017-02-09T10:51:29Z","body":"@ezrast Hey, that's a really nice use case, and it shows how sometimes one can be very expressive in the language. I don't know if other statically typed languages allow something like the above.\r\n\r\nThe good news is that this is fixable. Even though a generic container should allow subtypes, when you write `T` inside a method there's no reason for that to mean \"`T` or any of its subclasses\". It makes more sense for type restrictions. So this will be possible in the next version :-)"}}
{"actor":{"display_login":"asterite"}}