Kroppeb
12/19/2022, 7:48 AMval x: Any? = get()
if (x is B || x is C) {
println(x.b()) // <-- "Unresolved reference: b"
}
where class C
implements intrface B
and b()
is a method defined in B
I calculated the following smart types (see image) and don't see why it's not finding working.
Is this a compiler bug?
Playground: https://pl.kotl.in/mbuF47NGkdmitriy.novozhilov
12/19/2022, 7:53 AMKroppeb
12/19/2022, 7:59 AMKroppeb
12/19/2022, 9:05 AMdmitriy.novozhilov
12/19/2022, 11:04 AMKroppeb
12/19/2022, 12:30 PMprintln
there is also an else branch. Now I know that the smartCastTypeOf(x)
is gonna be Any
but, I don't see how to get the actual SmartCastType
.Kroppeb
12/19/2022, 12:33 PMLUB(C, ⊥) × GLB(B, LUB(B, C))
and I assume that GLB(X, LUB(Y, Z)) == LUB(GLB(X, Y), GLB(X, Z))
but I can't seem to find that anywhere in the specs.dmitriy.novozhilov
12/19/2022, 12:36 PMAny
appeared in your calculations
All we know for else
branch is that x !is B && x !is C
. It does not prevent x
to be any other type, including Nothing?
dmitriy.novozhilov
12/19/2022, 12:36 PMKroppeb
12/19/2022, 12:37 PMAny?
, I have just been using java and forgot nullability was a thing 😃dmitriy.novozhilov
12/19/2022, 12:40 PMKroppeb
12/19/2022, 12:48 PMKroppeb
12/19/2022, 12:48 PMdmitriy.novozhilov
12/19/2022, 12:52 PMKroppeb
12/19/2022, 12:53 PMdmitriy.novozhilov
12/19/2022, 12:57 PMmodel.kt
, statements.kt
, DfaVariables
.kt and Flow.kt
describes main entities used in DFA
◦ Flow
is a information about smartcasts which we pass by edges of control flow graph
◦ LogicSystem
is a class with implementation of different operations over Flow
• FirDataFlowAnalyzer is a main class which analyses all possible nodes in FIR tree and changes flow according to semanticKroppeb
12/19/2022, 1:09 PM