Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

allow is and as checks on generic parameters #236

Closed
jmesserly opened this issue Jun 22, 2015 · 4 comments
Closed

allow is and as checks on generic parameters #236

jmesserly opened this issue Jun 22, 2015 · 4 comments

Comments

@jmesserly
Copy link
Contributor

I think we need to come up with something here. For example:
http://www.dartdocs.org/documentation/matcher/0.12.0%2B1/index.html#matcher/matcher

see discussion around here
#103 (comment)

@jmesserly jmesserly added the task label Jun 22, 2015
@jmesserly
Copy link
Contributor Author

given

class SomeType<T> {
  bool test(x) => x is T;
}
main() => new SomeType<List<int>>().test(<Object>[123]);

options:

  • (1) reject statically at instantiation of SomeType<T> ... in other words, there's an implicit constraint that T supports is. (variant: reject at runtime, during instance construction)
  • (2) reject at runtime is, if type tested is a non-ground type (so, inside test)
  • (3) reject at runtime is, but only if results differ from standard Dart is check
  • (4) always have is using Dart semantics, provide a DDC helper library for our subtype check. (variant: the inverse of this)

Based on previous discussions, I think we're leaning towards (3).

CC @leafpetersen @vsmenon

@jmesserly
Copy link
Contributor Author

We won't be able to run a lot of tests until we can support this, so kind of high priority

@vsmenon
Copy link
Contributor

vsmenon commented Aug 12, 2015

We need to resolve this to nail down our checking rules as well. I think (3) is probably the best option here. We should perhaps still generate an "info" in this case.

@jmesserly
Copy link
Contributor Author

tagging Angular ... while it might not affect runtime, it'll block all tests, which would make developing an Angular app hard :)

@vsmenon vsmenon changed the title type checks on generic parameters allow is and as checks on generic parameters Aug 14, 2015
@vsmenon vsmenon self-assigned this Aug 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants