You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we cannot use generic types as Type argument. For example if I have a function foo(Type t), foo(int) and foo(Object) are valid, but foo(List<int>) is not, with error message
Error: A comparison expression can't be an operand of another comparison expression.
I don't know if there's any reason to parse< in (List<int>) as comparison.
I am told that one workaround is:
class TypeOf<T> {
Type get type => T;
}
TypeOf<List<int>>().type
or
Type typeOf<T> () => T;
typeOf<List<int>>()
Another way I did is using <int>[].runtimeType.
One problem with all these solutions are it cannot generate a const Type.
But I'm thinking maybe including such parser would be more elegant in the language.
The text was updated successfully, but these errors were encountered:
Currently we cannot use generic types as Type argument. For example if I have a function
foo(Type t)
,foo(int)
andfoo(Object)
are valid, butfoo(List<int>)
is not, with error messageI don't know if there's any reason to parse
<
in(List<int>)
as comparison.I am told that one workaround is:
or
Another way I did is using
<int>[].runtimeType
.One problem with all these solutions are it cannot generate a
const Type
.But I'm thinking maybe including such parser would be more elegant in the language.
The text was updated successfully, but these errors were encountered: