{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/31371","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/31371/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/31371/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/31371/events","html_url":"https://github.com/dart-lang/sdk/issues/31371","id":273946208,"number":31371,"title":"Cannot preserve reified type in general","user":{"login":"vsmenon","id":2119553,"avatar_url":"https://avatars0.githubusercontent.com/u/2119553?v=4","gravatar_id":"","url":"https://api.github.com/users/vsmenon","html_url":"https://github.com/vsmenon","followers_url":"https://api.github.com/users/vsmenon/followers","following_url":"https://api.github.com/users/vsmenon/following{/other_user}","gists_url":"https://api.github.com/users/vsmenon/gists{/gist_id}","starred_url":"https://api.github.com/users/vsmenon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsmenon/subscriptions","organizations_url":"https://api.github.com/users/vsmenon/orgs","repos_url":"https://api.github.com/users/vsmenon/repos","events_url":"https://api.github.com/users/vsmenon/events{/privacy}","received_events_url":"https://api.github.com/users/vsmenon/received_events","type":"User","site_admin":false},"labels":[{"id":219928175,"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-language","name":"area-language","color":"c7def8","default":false},{"id":219928184,"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-library","name":"area-library","color":"c7def8","default":false},{"id":219928211,"url":"https://api.github.com/repos/dart-lang/sdk/labels/P0%20critical","name":"P0 critical","color":"e11d21","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-11-14T21:18:09Z","updated_at":"2017-11-17T10:03:13Z","closed_at":null,"author_association":"MEMBER","body":"The following code fails at runtime with `'UnmodifiableMapView' is not a subtype of type 'Map<String, List<int>>'` - we currently have no way of typing this correctly.\r\n\r\nThis is blocking an internal team.\r\n\r\n```\r\nObject freeze(Object obj) {\r\n  if (obj is List) {\r\n    return new List.unmodifiable(obj.map(freeze)); // ObservableList in internal example\r\n  } else if (obj is Map) {\r\n    obj.forEach((k, v) {\r\n      obj[k] = freeze(v);\r\n    });\r\n    return obj;\r\n  }\r\n  return obj;\r\n}\r\n\r\nvoid main() {\r\n  var data = <String, List<int>> {\r\n    'hello': [1, 2],\r\n    'world': [3, 4],\r\n  };\r\n  print(data.runtimeType);\r\n  data = freeze(data);\r\n  print(data.runtimeType);\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/345199483","html_url":"https://github.com/dart-lang/sdk/issues/31371#issuecomment-345199483","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/31371","id":345199483,"user":{"login":"lrhn","id":4865287,"avatar_url":"https://avatars3.githubusercontent.com/u/4865287?v=4","gravatar_id":"","url":"https://api.github.com/users/lrhn","html_url":"https://github.com/lrhn","followers_url":"https://api.github.com/users/lrhn/followers","following_url":"https://api.github.com/users/lrhn/following{/other_user}","gists_url":"https://api.github.com/users/lrhn/gists{/gist_id}","starred_url":"https://api.github.com/users/lrhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrhn/subscriptions","organizations_url":"https://api.github.com/users/lrhn/orgs","repos_url":"https://api.github.com/users/lrhn/repos","events_url":"https://api.github.com/users/lrhn/events{/privacy}","received_events_url":"https://api.github.com/users/lrhn/received_events","type":"User","site_admin":false},"created_at":"2017-11-17T10:03:13Z","updated_at":"2017-11-17T10:03:13Z","author_association":"MEMBER","body":"The scope of `object is List<?X>` would be the code directly gated by that test. That is, the same places where we would do type promotion of `object` due to the `is` check. In fact, the static type of `object` would be promoted to `List<X>` in that scope.\r\n\r\nIt's similar to the idea of introducing new variables in type checks, like `x is List<int> list` which would introduce `list` as the type-promoted version of the value of `x` in the following scope. It works even if `x` cannot be promoted itself (e.g., because it's not a local variable)."}}
{"actor":{"display_login":"lrhn"}}