Ahmed Mourad
06/15/2020, 6:09 PMpublic
to lower values.
So, I created this a synthetic resolver with this method:
override fun generateSyntheticMethods(
thisDescriptor: ClassDescriptor,
name: Name,
bindingContext: BindingContext,
fromSupertypes: List<SimpleFunctionDescriptor>,
result: MutableCollection<SimpleFunctionDescriptor>
) {
/* ... */
result.elementAt(methodIndex).let { descriptor ->
val replacement = descriptor.createCustomCopy {
it.newCopyBuilder().setVisibility(newVisibility)
}
result.remove(descriptor)
result.add(replacement)
}
}
This works for if newVisibility
is private
and protected
but does not work if it's internal
and gives this error:
Exception in thread "main" java.lang.NoSuchMethodError: dev.ahmedmourad.sample.SomeClass.functionName$ModuleName(Ljava/lang/String;)Ldev/ahmedmourad/sample/SomeClass;
at dev.ahmedmourad.sample.MainKt.main(Main.kt:25)
at dev.ahmedmourad.sample.MainKt.main(Main.kt)
I know that the internal
modifier doesn't exist in the JVM and that synthetic methods are used to simulate it, so I guess I need to create a synthetic method whenever I change access to internal
, how and where do I do that?rnett
06/17/2020, 12:18 AM