-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow typing leads to incorrect "pattern type is incompatible with expected type" error #18083
Labels
Milestone
Comments
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jun 28, 2023
Improve logic when to emit "pattern type is incompatible with expected type" error. Fixes scala#18083 The whole thing is not very satisfactory. We have an approximation which has both false positives and false negatives. False positives: We are too lenient for numeric types and and/or types False negatives: We ignore user-generated equals methods The new approximation seems to be somewhat better than the old, but it's still an approximation. It begs the question why we attempt to do this at all.
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jun 28, 2023
Improve logic when to emit "pattern type is incompatible with expected type" error. Fixes scala#18083 The whole thing is not very satisfactory. We have an approximation which has both false positives and false negatives. False positives: We are too lenient for numeric types and and/or types False negatives: We ignore user-generated equals methods The new approximation seems to be somewhat better than the old, but it's still an approximation. It begs the question why we attempt to do this at all.
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jun 28, 2023
Improve logic when to emit "pattern type is incompatible with expected type" error. Fixes scala#18083 The whole thing is not very satisfactory. We have an approximation which has both false positives and false negatives. False positives: We are too lenient for numeric types and and/or types False negatives: We ignore user-generated equals methods The new approximation seems to be somewhat better than the old, but it's still an approximation. It begs the question why we attempt to do this at all.
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jun 29, 2023
Improve logic when to emit "pattern type is incompatible with expected type" error. Fixes scala#18083 The whole thing is not very satisfactory. We have an approximation which has both false positives and false negatives. False positives: We are too lenient for numeric types and and/or types False negatives: We ignore user-generated equals methods The new approximation seems to be somewhat better than the old, but it's still an approximation. It begs the question why we attempt to do this at all.
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jul 5, 2023
Improve logic when to emit "pattern type is incompatible with expected type" error. Fixes scala#18083 The whole thing is not very satisfactory. We have an approximation which has both false positives and false negatives. False positives: We are too lenient for numeric types and and/or types False negatives: We ignore user-generated equals methods The new approximation seems to be somewhat better than the old, but it's still an approximation. It begs the question why we attempt to do this at all.
odersky
added a commit
that referenced
this issue
Jul 6, 2023
Improve logic when to emit "pattern type is incompatible with expected type" error. Fixes #18083 The whole thing is not very satisfactory. We have an approximation which has both false positives and false negatives. False positives: We are too lenient for numeric types and and/or types False negatives: We ignore user-generated equals methods The new approximation seems to be somewhat better than the old, but it's still an approximation. It begs the question why we attempt to do this at all.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiler version
3.3.1-RC1 with
-Yexplicit-nulls
Minimized code
Output
Expectation
No error since
Sub2
is a valid subtype ofA
. The problem is that the selectorx
gets typed asx.type & A
instead ofx.type
(in toNotNullTermRef) which means the call to.widen
in https://github.com/lampepfl/dotty/blob/484be60846be17acee74cfe1c6ea16c10894303f/compiler/src/dotty/tools/dotc/typer/Typer.scala#L1750 doesn't actually widen the singleton.The text was updated successfully, but these errors were encountered: