{"action":"created","issue":{"url":"https://api.github.com/repos/lampepfl/dotty/issues/888","labels_url":"https://api.github.com/repos/lampepfl/dotty/issues/888/labels{/name}","comments_url":"https://api.github.com/repos/lampepfl/dotty/issues/888/comments","events_url":"https://api.github.com/repos/lampepfl/dotty/issues/888/events","html_url":"https://github.com/lampepfl/dotty/pull/888","id":114255327,"number":888,"title":"Check that union types do not contain singleton types.","user":{"login":"odersky","id":795990,"avatar_url":"https://avatars.githubusercontent.com/u/795990?v=3","gravatar_id":"","url":"https://api.github.com/users/odersky","html_url":"https://github.com/odersky","followers_url":"https://api.github.com/users/odersky/followers","following_url":"https://api.github.com/users/odersky/following{/other_user}","gists_url":"https://api.github.com/users/odersky/gists{/gist_id}","starred_url":"https://api.github.com/users/odersky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odersky/subscriptions","organizations_url":"https://api.github.com/users/odersky/orgs","repos_url":"https://api.github.com/users/odersky/repos","events_url":"https://api.github.com/users/odersky/events{/privacy}","received_events_url":"https://api.github.com/users/odersky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-30T11:50:04Z","updated_at":"2015-10-30T13:22:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/888","html_url":"https://github.com/lampepfl/dotty/pull/888","diff_url":"https://github.com/lampepfl/dotty/pull/888.diff","patch_url":"https://github.com/lampepfl/dotty/pull/888.patch"},"body":"Review by @smarter. Replaces #885.\r\n"},"comment":{"url":"https://api.github.com/repos/lampepfl/dotty/issues/comments/152523654","html_url":"https://github.com/lampepfl/dotty/pull/888#issuecomment-152523654","issue_url":"https://api.github.com/repos/lampepfl/dotty/issues/888","id":152523654,"user":{"login":"smarter","id":63430,"avatar_url":"https://avatars.githubusercontent.com/u/63430?v=3","gravatar_id":"","url":"https://api.github.com/users/smarter","html_url":"https://github.com/smarter","followers_url":"https://api.github.com/users/smarter/followers","following_url":"https://api.github.com/users/smarter/following{/other_user}","gists_url":"https://api.github.com/users/smarter/gists{/gist_id}","starred_url":"https://api.github.com/users/smarter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarter/subscriptions","organizations_url":"https://api.github.com/users/smarter/orgs","repos_url":"https://api.github.com/users/smarter/repos","events_url":"https://api.github.com/users/smarter/events{/privacy}","received_events_url":"https://api.github.com/users/smarter/received_events","type":"User","site_admin":false},"created_at":"2015-10-30T13:22:37Z","updated_at":"2015-10-30T13:22:37Z","body":"I'm not a fan of this because it reduces expressiveness. You said \"If we want lubs to widen singleton types we have to disallow union types consisting of singleton types\" and I believe that `lub` should not widen by default. Instead if we know that we need to widen at a certain point, we can do it explicitly.\r\n\r\nMore practically, just disallowing singleton types in unions does not fix everything, consider:\r\n```scala\r\ncase class Sing[T <: Singleton]()\r\nobject Sing {\r\n  def apply[T <: Singleton]: Sing[T] = null.asInstanceOf[Sing[T]]\r\n}\r\n\r\nobject Test {\r\n  def oneOrTwo(x: Sing[1] | Sing[2]): Sing[1] | Sing[2] = x\r\n  def test: Unit = {\r\n    val foo: Sing[3] | Sing[4] = Sing[1]()\r\n    oneOrTwo(foo)\r\n  }\r\n}\r\n```\r\nThis compiles fine even with this pull request, because we distribute the `|` and call `lub` while doing so. Compiling with `-Xprint-types` shows that `Sing[1] | Sing[2]` is \"simplified\" as `Sing[_ <: Int]`"}}