You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Took a look, and I'm convinced the behavior is undefensible.
The given snippet not only compiles in scalac, but also makes some sense, and the error is false: LetRis a subtype of Tree.
The problem is that Tree is sealed, but inheriting classes can be created in different contexts in the same file. (In stranger cases, that has quite weird consequences — you can define alternatives that you can't match on and that might not exist).
So, either LetR should be forbidden because of sealed, if this code is now undesired, or the pattern matcher should be fixed to allow this code.
About the feature itself: I happened to create code like this recently, though I didn't expect it to work, and it turned out to be nice (in specific scenarios), where I wanted separate modules in the same file to add alternatives to my ADT. However, that seem a very weird feature.
Following code compiles in scalac, but in dotty it generates following error message:
The text was updated successfully, but these errors were encountered: