You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a java method overrides a kotlin property declaration, calling javaMethod.asMemberOf(javaType) throws unsupported operation exception.
e.g.
interface MyKotlinInterface {
val x:Int
var y:Int
}
class JavaImpl implements MyKotlinInterface { // remove implements and it will work fine
public int getX() {
return 1;
}
public int getY() {
return 1;
}
public void setY(int value) {
}
}
This might be related to #248 but not sure. Hit this while updating Room to beta01.
stacktrace:
error: [ksp] java.lang.UnsupportedOperationException
at org.jetbrains.kotlin.descriptors.impl.PropertyAccessorDescriptorImpl.substitute(PropertyAccessorDescriptorImpl.java:122)
at org.jetbrains.kotlin.descriptors.impl.PropertyAccessorDescriptorImpl.substitute(PropertyAccessorDescriptorImpl.java:31)
at org.jetbrains.kotlin.resolve.calls.inference.DescriptorRelatedInferenceUtilsKt.substitute(DescriptorRelatedInferenceUtils.kt:42)
at com.google.devtools.ksp.processing.impl.ResolverImpl.computeAsMemberOf(ResolverImpl.kt:757)
at com.google.devtools.ksp.processing.impl.ResolverImpl.asMemberOf$compiler_plugin(ResolverImpl.kt:735)
at com.google.devtools.ksp.symbol.impl.java.KSFunctionDeclarationJavaImpl.asMemberOf(KSFunctionDeclarationJavaImpl.kt:121)
The text was updated successfully, but these errors were encountered:
* KSP beta01 introduces an api change in function overrides where it can
handle cases when a java method overrides a kotlin property. This also
means the return type of `KSFunction.findOverridee` is a KSDeclaration
instead of KSFunction. We use this when resolving types so I've updated
Room to expect a property declaration as well. It was also affecting
override variance resolution but that code only ever runs for kotlin
sources so it was not necessary to handle property overrides there.
* Adding more tests to java overriding kotlin property revelated another
bug where we were setting an invalid parameter name for property setter
values. (<set-?>). That name is valid in byte code but not in source
code. I've updated JavacVariableElement and KotlinSynthetic to use a
sanitized name instead. We could've done it while generating code but
since many other things refer to these parameters, it is safer to do it
while parsing parameters and hide the detail from the rest of the
processing.
* One of the new tests I've added hit a bug in KSP that revelated after
KSP fixed "java method overrides kotlin property" case. Added a try
catch helper for it:
google/ksp#462
* Previously, when listing methods in a kotlin class, we always listed
setters before getters which made the source code match tests slightly
more difficult. Changed it to keep setter/getter of a property together
in the methods list.
* KSP changed its processor provider interface, updated Room
accordingly. (it now receives 1 container object instead of multiple
parameters)
Bug: 160322705
Test: existing tests + more tests for overrides
Change-Id: I92ec446b59cdeccc37bd91308d1a20acf3fe959a
The KSP bug around java overriding kotlin properties is now
fixed hence we don't need the workaround anymore.
Issue: google/ksp#462
Bug: 160322705
Test: existing tests pass without the workaround
Change-Id: I36b0b0b83f314738d4decc5d8acccb71aef50b20
When a java method overrides a kotlin property declaration, calling
javaMethod.asMemberOf(javaType)
throws unsupported operation exception.e.g.
This test throws the exception:
Full repro: yigit@f703801
This might be related to #248 but not sure. Hit this while updating Room to beta01.
stacktrace:
The text was updated successfully, but these errors were encountered: