Alexander Ioffe
01/26/2025, 7:27 PMfun <T: SomethingIDontKnow> stuff(value: Foo<T>)
is actually valid for some value Foo<SomethingElseIDontKnow>
? Is there some way to typecheck the IrCall stuff(somethingIDontKnow)
or compare the two IrType instances Foo<T>
(from valueParamters[0] of stuff
) and Foo<SomethingElseIDontKnow>
? I tried using IrTypeSystem.Context.intersectTypes but that doesn't do the right thing.dmitriy.novozhilov
01/27/2025, 8:50 AMSomethingIDontKnow
?
You know all the types at IR levelAlexander Ioffe
01/27/2025, 3:57 PMAlexander Ioffe
01/27/2025, 4:49 PMJavier
01/27/2025, 4:51 PMAbstractTypeChecker.isSubtypeOf
was not covering that use case.Javier
01/27/2025, 4:52 PMAlexander Ioffe
01/27/2025, 5:42 PMJavier
01/27/2025, 6:27 PMAlexander Ioffe
01/27/2025, 7:11 PMProofResolutionStageRunner
?Javier
01/27/2025, 7:12 PMAlexander Ioffe
01/27/2025, 7:13 PMConeKotlinType
?Alexander Ioffe
01/27/2025, 7:19 PMJavier
01/27/2025, 7:22 PMAlexander Ioffe
01/27/2025, 7:23 PMJavier
01/27/2025, 7:33 PMAlexander Ioffe
01/28/2025, 12:35 AMKind<F, T>
or something like that?Javier
01/28/2025, 12:56 AMBox<T>
, and another proof that can be Foo
. If you want to get the proof Box<Foo>
, we needed to check if it was applicable with that approachJavier
01/28/2025, 12:59 AMinterface Foo
class Bar : Foo
provides -> Box<T>
provides -> Bar()
ask for -> Box<Foo>
As you are not asking for the exact same type, but it is indeed compatible because you the two compatible types in the graph, it must allow getting Box<Foo>
. Without that, we can only compare exact same type, so Box<Bar>
would work but Box<Foo>
not.dmitriy.novozhilov
01/28/2025, 7:42 AMI think this is similar to the feature request I asked for to detect if a type is compatible with another type asIf we are talking about just checking the applicability of the single argument to the single parameter thenwas not covering that use case.AbstractTypeChecker.isSubtypeOf
isSubtypeOf
is completely suitable. Just substitute the T
in parameter with actual type argument.
But if we are talking about inferring T
at IR level, then there is no such API. The compiler does the inference stuff at the fronted level