Skip to content

Commit

Permalink
Switch to new alpha K2 compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
DenWav committed Aug 17, 2022
1 parent b76e370 commit 5530d6a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ tasks.withType<JavaCompile>().configureEach {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
freeCompilerArgs = listOf("-Xjvm-default=all")
freeCompilerArgs = listOf("-Xuse-k2", "-Xjvm-default=all", "-Xjdk-release=11")
kotlinDaemonJvmArguments.add("-Xmx1G")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class AtCompletionContributor : CompletionContributor() {

val entry = memberName.parent as? AtEntry ?: return

val entryClass = entry.className.classNameValue ?: return
val entryClass = entry.className?.classNameValue ?: return

val module = ModuleUtilCore.findModuleForPsiElement(memberName) ?: return
val project = module.project
Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/translations/TranslationFiles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ object TranslationFiles {
file?.nameWithoutExtension?.lowercase(Locale.ENGLISH)

tailrec fun seekTranslation(element: PsiElement): PsiNamedElement? {
return toTranslation(element)?.let { element as? PsiNamedElement }
?: seekTranslation(element.parent ?: return null)
// don't use elvis here, K2 doesn't think it's a tail recursive call if you do
val res = toTranslation(element)?.let { element as? PsiNamedElement }
if (res != null) {
return res
}
return seekTranslation(element.parent ?: return null)
}

fun toTranslation(element: PsiElement): Translation? =
Expand Down

0 comments on commit 5530d6a

Please sign in to comment.