The title basically says it.
Is there a way to use the type of e. g. new Object {def foo = "bar"} in an isInstanceOf[<structural_type_here>] call?
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.
Structural types will not work with
isInstanceOf. Likewise, pattern matches to structural types are meaningless (they always match).This is usually blamed on type erasure, but even in the absence of erasure it would not work, since JVM does not understand structural types.
On the other hand, Scala could have been smart enough to make structural type checking work through erasure.