File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -338,9 +338,15 @@ object Tuple:
338
338
*/
339
339
transparent inline def indexOf (y : Any ): Int = constValue[IndexOf [X , y.type ]]
340
340
341
- /** A boolean indicating whether there is an element `y.type` in the type `X` of `x`
342
- */
343
- transparent inline def contains (y : Any ): Boolean = constValue[Contains [X , y.type ]]
341
+ /** A boolean indicating whether there is an element `y.type` in the type `X` of `x` */
342
+ // Note this isn't equivalent to `constValue[Contains[X, y.type]]`
343
+ // since it also accepts cases unknown at compiletime.
344
+ // Also note it would be unsound to use a type parameter for `y` in the
345
+ // type level `Contains`, since it is rightfully not covariant in `Y`.
346
+ inline def contains (y : Any ): Contains [X , y.type ] =
347
+ x.productIterator.contains(y).asInstanceOf [Contains [X , y.type ]]
348
+
349
+ // TODO containsType ?
344
350
345
351
end extension
346
352
You can’t perform that action at this time.
0 commit comments