void main() {
Test1<(int, int)>(); // false??
print(identical((int, int), (int, int))); // true
Test2<int>(); // true
Test3<Test<Name>>(); // true
}
class Test1<T> {
Test1() {
print(identical((int, int), T));
}
}
class Test2<T> {
Test2() {
print(identical(int, T));
}
}
class Test3<T> {
Test3() {
final t = Test<Name>;
print(identical(Test<Name>, T));
}
}
class Test<T> {
final T test;
Test(this.test);
}
class Name {
final String value;
const Name(this.value);
@override
String toString() => value;
}
I was playing around with the new Record feature in Dart 3 alpha, basically trying out some things with Records when used as generic types,
Doing so, some unexpected failing Record Type checks were failing, so I made a little test to reproduce this.
The first test is the one which fails for me, (int, int) and T also have different hash codes, regardless if that is intentional or not, there is then no way to do something like T is (int, int) for example.
So the question is, is this behavior expected? And if so, would there be any way to properly cast a Record Type, like T is (int, int)?void main() {
Test1<(int, int)>(); // false??
print(identical((int, int), (int, int))); // true
Test2<int>(); // true
Test3<Test<Name>>(); // true
}
class Test1<T> {
Test1() {
print(identical((int, int), T));
}
}
class Test2<T> {
Test2() {
print(identical(int, T));
}
}
class Test3<T> {
Test3() {
final t = Test<Name>;
print(identical(Test<Name>, T));
}
}
class Test<T> {
final T test;
Test(this.test);
}
class Name {
final String value;
const Name(this.value);
@override
String toString() => value;
}
--
For more ways to connect visit https://dart.dev/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CAFBTw7i2pTZR9esuvP11mq58%2BSeZvS9g1Zm_sYVy-jpAS8JMgw%40mail.gmail.com.
var x = (int, int);
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CACDCfDTgcCUwoYP96Ey0fSo%2BHv9ocRcN8UhKvKu_ZKBWu8_18w%40mail.gmail.com.