Selectively disable subsumption in Scala? (correctly type List.contains)
问题 List("a").contains(5) Because an Int can never be contained in a list of String , this should generate an error at compile-time , but it does not. It wastefully and silently tests every String contained in the list for equality to 5 , which can never be true ( "5" never equals 5 in Scala). This has been named "the 'contains' problem". And some have implied that if a type system cannot correctly type such semantics, then why go through the extra effort for enforcing types. So I consider it is