dart-lang / dart-lang/language

Allow type-checking type variables

Open
#459 13 comments 30 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

I often see people trying to check the type of a type variable by doing `if (T is int) ...`.
This doesn't work, the expression `T` evaluates to a `Type` object which is not of type `int`.
The idea has merit, though.

We could perhaps special case `typeVariable is type` to actually check whether the type of `typeVariable` is a subtype of `type`. The expression is useless otherwise, so it's not like we will break any reasonable program, and users obviously find the syntax intuitive, since they keep using it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.