-
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
Matching on Option[Option[T]] where T is abstract and obtained from inline def in super trait emits exhaustivity warning #16435
Comments
Nevertheless, the original snippet is definitely a bug in the exhaustivity checker that was here even in 3.0.0. |
No, no ideas why it being transparent changes things. But I can look. |
That |
This appears to be a type avoidance problem. After inlining, we have: {
val Base_this: (X.this : X) = this
None:Option[Option[Base_this.Value]]
} match { ... so the scrutinee's type now refers to That explains why the various workarounds work. (The |
It's tempting to just slap an The inliner already has special logic around |
Seems like an avoidance bug, also reproducible by hand: class A:
type X
def foo =
val local: this.type = this
val x: Option[local.X] = None
x
|
Dale, we touched on that possibility but you speculated it would probably be “too expensive”, want to expand on that thought? |
Looks like this is caused by the use of tryWiden in https://github.com/lampepfl/dotty/blob/ef653b6a31180416ff6b7fdc432e9ef0343b7075/compiler/src/dotty/tools/dotc/core/TypeOps.scala#L495-L507 |
Compiler version
Scala 3.2.1
Minimized code
Output
The compiler emits the following warning:
Expectation
The code should compile.
Workarounds
We have found three ways to make the code compile without this warning and one that gives a new unexpected error:
Extract
oov
to local valueRemove
inline
Without the
inline
modifier, the code compiles:Make type
Value
concreteAdding
transparent
toinline
results in new errorThis code
causes the compiler to emit this error:
The text was updated successfully, but these errors were encountered: