We have another solution on the table: `x` in `x a...
# language-proposals
d
We have another solution on the table:
x
in
x as T
should be resolved with an expected type T. So, code like
findViewById(...) as MyView
would work as it did before.
r
I don't entirely understand this. I assume this would only affect calls to generic functions. Would it convert
findViewById(...) as MyView
to
findViewById<MyView>(...)
, or would it just be some sort of compiler intrinsic (since the type is erased anyway)?
d
When you infer types for a generic call, there's an "expected type" for an expression that is taken into account as an additional constraint. So yes, it will affect inference for other expressions as well, although from our practice it's usually what people actually expect writing code like
foo() as Bar
.
r
Ah, I see. For some reason I didn't realize you meant it would be part of type inference. Thanks for the explanation 🙂