-
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
Fix #13197: Deskolemize lifted named arguments #13590
Fix #13197: Deskolemize lifted named arguments #13590
Conversation
This bug only happens when the function is inlined. @smarter Could you have a look of the code? I'm not sure whether this is the correct fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think widen
should look inside types, this would be a big departure from its current behavior.
(?1 : String | Null)
looks like a skolem and we have logic to widen skolem when ascribing a type to a val during typer: https://github.com/lampepfl/dotty/blob/aaac006a58c3f5d7fbd64d3a1a19261b51dfecf5/compiler/src/dotty/tools/dotc/typer/Namer.scala#L1707 It seems like the same logic should be used when we ascribe a type to a val during the inlining phase?
@smarter This could also be a bug from named parameters. extension [T](x: T | String) inline def forceString: x.type & String =
x.asInstanceOf
trait Bar:
def b: String | Int
class Foo(a: String = "", b: String)
object Foo:
def foo(bar: Bar) = Foo(b = bar.b.forceString) In typer, we can see the function def foo(bar: Bar): Foo = {
val b$1: (?1 : String | Int) & String = forceString[Int](bar.b)
val a$1: String @uncheckedVariance = Foo.$lessinit$greater$default$1
new Foo(a$1, b = b$1)
} I think we need to widen the skolem type for |
Yes that looks like the root of the problem indeed. |
2cca082
to
d4cbbe5
Compare
Fix #13197
The lift named arguments contain skolem types, which causes checker in inliner to fail.
We add
deskolemized
to fix this issue.