Skip to content

Commit

Permalink
Fix override modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
natario1 committed Sep 8, 2024
1 parent bc43c63 commit 17f0adc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
script: cd tests && ./gradlew connectedCheck
script: cd tests && ./gradlew connectedCheck --stacktrace
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
distribution: temurin
cache: gradle
- name: Publish to Maven Central
run: ./gradlew deployNexus
run: ./gradlew deployNexus --stacktrace
- name: Publish to GitHub Packages
run: ./gradlew deployGithub
run: ./gradlew deployGithub --stacktrace
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
distribution: temurin
cache: gradle
- name: Publish Nexus Snapshot
run: ./gradlew deployNexusSnapshot
run: ./gradlew deployNexusSnapshot --stacktrace
12 changes: 10 additions & 2 deletions knee-compiler-plugin/src/main/kotlin/DownwardFunctions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.backend.common.lower.irCatch
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
import org.jetbrains.kotlin.ir.builders.declarations.buildVariable
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
Expand Down Expand Up @@ -59,7 +58,16 @@ private fun KneeDownwardFunction.makeCodegen(codegen: KneeCodegen, signature: Do
if (source.isSuspend) {
addModifiers(KModifier.SUSPEND)
}
if (kind is Kind.InterfaceMember || (source as? IrSimpleFunction)?.overriddenSymbols?.isNotEmpty() == true) {
// Needs override: (source as? IrSimpleFunction)?.overriddenSymbols?.isNotEmpty() == true
// But the JVM hierarchy doesn't match the KN hierarchy, supertypes may be missing, so this needs to be treated differently.
// Could merge this logic with that of DownwardProperties
val isOverride = when {
kind is Kind.InterfaceMember -> true
source !is IrSimpleFunction -> false
source.overriddenSymbols.any { it.owner.parentClassOrNull?.defaultType?.isAny() == true } -> true // toString(), equals() or hashCode()
else -> false
}
if (isOverride) {
addModifiers(KModifier.OVERRIDE)
}
}
Expand Down

0 comments on commit 17f0adc

Please sign in to comment.