@@ -118,6 +118,7 @@ or if *T* is not a compile-time constant type. It is a compile-time error if any
118
118
override ` Object.operator== ` unless they are instances of ` int ` or ` String ` , objects implementing ` Symbol ` originally created by
119
119
a symbol literal or a constant invocation of the ` Symbol ` constructor, or objects implementing ` Type ` originally created by
120
120
a constant type literal expression.
121
+ It is a compile-time error if any two of the values are equal according to ` == ` .
121
122
122
123
Let * e<sub >1</sub >* … * e<sub >n</sub >* be the constant element expressions of * s* in source order,
123
124
and let * v* <sub >1</sub > … * v<sub >n</sub >* be their respective constant values.
@@ -315,9 +316,9 @@ Set v15 = const {4} // const Set<dynamic>
315
316
316
317
var v16 = {1, 2, 3, 2, 1}; // LinkedHashSet<int>
317
318
var l16 = x.toList(); // -> <int>[1, 2, 3]
318
- const v17 = {1, 2, 3, 2, 1}; // const Set<int>
319
- var l17 = x.toList(); // -> <int>[ 1, 2, 3]
320
- // v17.add(42); // throws, immutable
319
+ // Compile-time error, contains equal elements
320
+ // const _ = { 1, 2, 3, 2, 1};
321
+
321
322
var l18 = const {1, 2} // const Set<int>
322
323
323
324
// Class overriding `==`.
@@ -336,9 +337,7 @@ print(v19); // {C(1, "a"), C(2, "a")}
336
337
337
338
const v20 = {1, 2, 3}; // const Set<int>
338
339
const v21 = {3, 2, 1}; // const Set<int>
339
- const v22 = {1, 1, 2, 3, 2, 1}; // const Set<int>
340
340
print(identical(v20, v21)); // -> false
341
- print(identical(v20, v22)); // -> true
342
341
343
342
// Type can be computed from element types.
344
343
var v23 = {1, 2.5} // LinkedHashSet<num>
0 commit comments