I just recently encountered the term “Weak Conformance” (in Stack Overflow user retronym‘s answer to How to set up implicit conversion to allow arithmetic between numeric types?).
What is it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Where is this used? For one thing, it determines the type of
ifexpressions:In Scala 2.7.x, this would by of type
AnyVal, the least uppper bound ofIntandDouble. In 2.8.x, it types asDouble.Similarly:
Another place it is used is in type inference:
And also for simple numeric widening:
UPDATE
As pointed out by Daniel, the spec is wrong about which types have weak conformance. Let’s ask the compiler itself: