https://kotlinlang.org logo
#ksp
Title
# ksp
d

Dmytro Serdiuk

03/11/2024, 12:17 PM
Hello! I saw next dirtiness propagation in ksp:
Copy code
Propagation by resolution tracing: Resolving a type reference (implicitly or explicitly) is the only way to navigate from one file to another. When a type reference is resolved by a processor, a changed or affected file that contains a change that may potentially affect the resolution result will affect the file containing that reference.
May I ask to explain with details or give some example? Thanks
@Ting-Yuan Huang, sorry for bothering, may I ask you for the support
t

Ting-Yuan Huang

03/11/2024, 5:39 PM
Suppose we are writing a processor that prints the return types of a
givenFunction
. This (file that contains the given) function is the root of the navigation and we associate it with the
output
. When this processor resolves references of the return type, e.g.,
givenFunction.returnType?.resolve()
, KSP associates the class definitions of the resolved type with the
output
as well. Processors' outputs depend on their inputs. In the above example, when the class definition of the
returnType
changes, the processor may observe the change and potentially produce something differently. Therefore a change in
returnType
needs to trigger re-processing of all files / elements required for
output
in the incremental build.
d

Dmytro Serdiuk

03/11/2024, 5:48 PM
thank you for your answer, @Ting-Yuan Huang But I thought that if you change the input file (like the definition of the givenFunction), the file would be already considered “dirty” and would be incrementally reprocessed.
Copy code
"A dirty file is either directly changed by users or indirectly affected by other dirty files."
so I didn’t get why this “resolution tracking” is something standalone? thank you!
t

Ting-Yuan Huang

03/11/2024, 6:02 PM
givenFunction
need not to be changed to be considered dirty. In this example, the dirtiness is propagated from the class definition of the return type.
d

Dmytro Serdiuk

03/11/2024, 6:03 PM
thank you very much for the explanation