https://kotlinlang.org logo
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
benchmarks
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
confetti
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
lincheck
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by
Title
v

Vadim Kapustin

05/27/2021, 11:30 AM
I tried to change in my project Kotlin 1.4.32 and Compose build190 to Kotlin 1.5.0 and Compose build210... When I rebuild my project I receive Internal compiler error (look in the thread). I tried other earlier builds including build198 with Kotlin 1.4.32 and had the same error. When I returned to build190, error disappeared. What should I do to upgrade to the newer builds?
java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:359)
	at java.base/java.util.ArrayList.get(ArrayList.java:427)
	at org.jetbrains.kotlin.ir.util.IrUtilsKt.getTypeSubstitutionMap(IrUtils.kt:540)
	at org.jetbrains.kotlin.ir.util.IrUtilsKt.getTypeSubstitutionMap(IrUtils.kt:554)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitCall(IrComposableAnnotator.kt:116)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitCall(IrElementVisitorVoid.kt:165)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitCall(IrComposableAnnotator.kt:60)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitCall(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
	at org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl.acceptChildren(IrVariableImpl.kt:77)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitElement(IrComposableAnnotator.kt:229)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitDeclaration(IrElementVisitorVoid.kt:40)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitDeclaration(IrComposableAnnotator.kt:215)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitVariable(IrElementVisitorVoid.kt:68)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitVariable(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitVariable(IrElementVisitorVoid.kt:69)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitVariable(IrComposableAnnotator.kt:60)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitVariable(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl.accept(IrVariableImpl.kt:74)
	at org.jetbrains.kotlin.ir.expressions.IrBlockBody.acceptChildren(IrBody.kt:57)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitElement(IrComposableAnnotator.kt:229)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitBody(IrElementVisitorVoid.kt:86)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitBody(IrComposableAnnotator.kt:192)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitBlockBody(IrElementVisitorVoid.kt:92)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitBlockBody(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitBlockBody(IrElementVisitorVoid.kt:93)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitBlockBody(IrComposableAnnotator.kt:60)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitBlockBody(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBody.kt:54)
	at org.jetbrains.kotlin.ir.declarations.IrFunction.acceptChildren(IrFunction.kt:61)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitElement(IrComposableAnnotator.kt:229)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitDeclaration(IrElementVisitorVoid.kt:40)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitDeclaration(IrComposableAnnotator.kt:215)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFunction(IrElementVisitorVoid.kt:49)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitFunction(IrComposableAnnotator.kt:81)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitSimpleFunction(IrElementVisitorVoid.kt:52)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitSimpleFunction(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitSimpleFunction(IrElementVisitorVoid.kt:53)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitSimpleFunction(IrComposableAnnotator.kt:60)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitSimpleFunction(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:28)
	at org.jetbrains.kotlin.ir.declarations.IrClass.acceptChildren(IrClass.kt:60)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitElement(IrComposableAnnotator.kt:229)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitDeclaration(IrElementVisitorVoid.kt:40)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitDeclaration(IrComposableAnnotator.kt:215)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitClass(IrElementVisitorVoid.kt:43)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitClass(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitClass(IrElementVisitorVoid.kt:44)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitClass(IrComposableAnnotator.kt:60)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitClass(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:55)
	at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.acceptChildren(IrFileImpl.kt:66)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitElement(IrComposableAnnotator.kt:229)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitPackageFragment(IrElementVisitorVoid.kt:30)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitPackageFragment(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFile(IrElementVisitorVoid.kt:37)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitFile(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid$DefaultImpls.visitFile(IrElementVisitorVoid.kt:38)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitFile(IrComposableAnnotator.kt:60)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotator.visitFile(IrComposableAnnotator.kt:60)
	at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.accept(IrFileImpl.kt:63)
	at org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl.acceptChildren(IrModuleFragmentImpl.kt:40)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoidKt.acceptChildrenVoid(IrElementVisitorVoid.kt:275)
	at androidx.compose.compiler.plugins.kotlin.lower.IrComposableAnnotatorKt.annotateComposableFunctions(IrComposableAnnotator.kt:56)
	at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:70)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$generateModule$1.invoke(JvmIrCodegenFactory.kt:93)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$generateModule$1.invoke(JvmIrCodegenFactory.kt:89)
	at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:91)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:106)
	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:595)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:211)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:154)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:386)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:110)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:286)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:99)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:114)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:74)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1659)
	at jdk.internal.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
j

jim

05/27/2021, 3:43 PM
Whenever I do major branch switches (for any project), I always blow away my gradle caches, because gradle is buggy as hell.
2
at the very least, a
./gradlew clean
and a
rm rf ~/.gradle
I also kill all the daemons associated with gradle (do a
jps -m
to find anything with the word Daemon in it)
v

Vadim Kapustin

05/28/2021, 11:04 AM
@jim I made all these steps -nothing has changed :(
I have a complex porject with two Compose applications. These applications use shared libraries also present in this project. Some libraries have a dependency on Compose, some don't. To set versions of external packages in the project I use the buildSrc directory which has a src/main/kotlin/Deps.kt file of the following format:
object Versions {
    const val kotlin = "1.5.0"
    const val compose = "0.4.0-build210"
    const val coroutines = "1.5.0"
    const val serialization = "1.2.0"

    // etc...
}

object Deps {
    object Kotlin {
        const val platform = "org.jetbrains.kotlin:kotlin-bom:${Versions.kotlin}"
        const val gradle_plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
        const val coroutines_core = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:${Versions.coroutines}"
        const val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.serialization}"
    }

    object Compose {
        const val gradle_plugin = "org.jetbrains.compose:compose-gradle-plugin:${Versions.compose}"
    }

    // etc...
}
File buildSrc/build.gradle.kts:
repositories {
    mavenCentral()
    gradlePluginPortal()
}

plugins {
    `kotlin-dsl` apply true
}

File settings.gradle.kts in project directory have following format:

pluginManagement {
    repositories {
        jcenter()
        gradlePluginPortal()
        maven { url = uri("<https://maven.pkg.jetbrains.space/public/p/compose/dev>") }
    }
}

include(
    ":application1",
    ":application2",
    ":libs:lib1",
    ":libs:lib2",
    ":libs:lib3",
    // etc...
)
File build.gradle.kts in project directory:
buildscript {
    repositories {
        mavenLocal().mavenContent {
            includeModule("org.jetbrains.compose", "compose-gradle-plugin")
        }
        google()
        jcenter()
        maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
    }

    dependencies {
        classpath("org.jetbrains.compose:compose-gradle-plugin:${Versions.compose}")
        classpath(kotlin("gradle-plugin", version = Versions.kotlin))
        classpath(kotlin("serialization", version = Versions.kotlin))
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
    }
}

subprojects {
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
    tasks.withType<Test> {
        useJUnitPlatform()
    }
}
Each application has a build.gradle.kts file in its directory:
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
    kotlin("jvm")
    kotlin("plugin.serialization")
    id("org.jetbrains.compose")
}

group = "..."
version = "..."

dependencies {
    implementation(compose.desktop.currentOs)
    implementation(Deps.Kotlin.serialization)
    implementation(Deps.Kotlin.coroutines_core)
    // etc...

    implementation(project(":libs:lib1"))
    implementation(project(":libs:lib2"))
    implementation(project(":libs:lib3"))
    // etc...
}

compose.desktop {
    application {
        mainClass = "project.application1.MainKt"
        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "Application1"
        }
    }
}
Each library from "libs" directory has a build.gradle.kts file in its directory:
plugins {
    kotlin("jvm")
    kotlin("plugin.serialization")
    id("org.jetbrains.compose")
}

group = "..."
version = "..."

dependencies {
    implementation(compose.desktop.currentOs)
    implementation(Deps.Kotlin.serialization)
    // etc...

    implementation(project(":libs:lib2"))
    implementation(project(":libs:lib3"))
}
Or if the library does not depend on Compose:
plugins {
    kotlin("jvm")
}

group = "..."
version = "..."

kotlin {
    dependencies {
        implementation(platform(Deps.Kotlin.platform))
        // etc...

        implementation(project(":libs:lib3"))
    }
}
This structure of the project provided its assembly without problems up to build190. But with build198, an internal compiler error began to appear. This is my first acquaintance with the Gradle build system and the Compose library, and in general with Kotlin. I had to review a lot of resources before building a project structure that satisfied me, but maybe there is some fundamental error in it that leads to the above problem...
j

jim

05/28/2021, 3:10 PM
Internal compile error is always a bug. If build190 worked and 198 breaks, it could be a regression in Kotlin since we recently upgraded major kotlin versions. If you can create+share a minimal repro, we can investigate further.
t

Thomas

05/29/2021, 2:47 PM
I have the same issue. It happened to me when upgrading Compose and other libraries to Kotlin 1.5. So it is hard to say what introduced this error. For me the issue was caused by some Kotlin code. The code is fine, it worked before, but for some reason it now causes this error. You should be able to see in the build log which gradle module has the issue. I have an abstract class with type parameters. That class was also extending another abstract class with type parameters. Another (final) class which extends the abstract class caused the error. When removing that class, or the type parameters completely, the error was gone for me. I think it is going to be quite difficult to make a minimal repo for this.
I found out the cause by just removing Kotlin files in the affected module until the project compiled. Then it was quite easy to just remove pieces of code in the affected file and that is how I found out the issue cause.
j

jim

05/29/2021, 3:00 PM
Even a non-minimal sample could be useful if you're able to share, although a minimal repro would be better :).
v

Vadim Kapustin

05/31/2021, 8:59 AM
@Thomas I have the same case!
abstract class A<Type1, Type2> {
  // ...
}

object C : A<Int, DataClass1> {
  // ...
}
This code works fine But when I add this code:
abstract class B<Type3> : A<Int, Type3> {
  // ...
}

object D : B<DataClass2> {
  // ...
}

object E : B<DataClass3> {
 // ...
}
I get the internal compiler error...
I only uncommented сlass B without objects and got the same error
t

Thomas

05/31/2021, 9:51 AM
Great to hear you found the issue
v

Vadim Kapustin

05/31/2021, 10:05 AM
I uncommented the class B in parts and checked when the error appears. If class A have open function:
abstract class A<Type1, Type2> {
  open fun test(key: Type1) : Type2
  // ...
}
The error only appeared when I uncommented the overloaded function
abstract class B<Type3> : A<Int, Type3> {
  override fun test(key: Int) : Type3 {
    // ...
    return super.test(key) // !!! The error occurs only when this line appears in the code !!!
  }
  // ...
}
@jim I can make minimal sample... Where is the best place to post this issue?
I make minimal sample with this error from Compose Desktop project template... When I try to use the same classes in Console Application project template - all works fine
t

Thomas

05/31/2021, 10:34 AM
Hmm can you try to add the kotlinx serialization dependency and plugin? Maybe that does something
I know that serialization had similar issues in the past but I do not know if it could be related.
Are you using Kotlin 1.5?
v

Vadim Kapustin

05/31/2021, 10:47 AM
This error appears on Compose build198 with Kotlin 1.4.32, and on Compose build210 with Kotlin 1.5.0
t

Thomas

05/31/2021, 10:49 AM
Yes but are you using 1.5 in the minimal sample you are trying to create?
I'm going to try build198 in my project and see what happens.
v

Vadim Kapustin

05/31/2021, 10:58 AM
In the console minimal sample I use Kotlin 1.5.10 and serialization 1.2.0. Also, I try Kotlin 1.4.32 and serialization 1.1.0 - also without errors. In the Compose minimal sample I use Kotlin 1.5.10 and Compose 0.4.0-rc2
I made a hack for my project:
abstract class A<Type1, Type2> {
  protected fun makeTest(key: Type1): Type2 {
    //...
  }
  open fun test(key: Type1) : Type2 = makeTest(key)
}

abstract class B<Type3> : A<Int, Type3> {
  override fun test(key: Int) : Type3 {
    // ...
    return makeTest(key) // now this works
  }
  // ...
}
t

Thomas

05/31/2021, 11:12 AM
I can reproduce the issue in my real project with build198 and Kotlin 1.4.32 as well. So it looks like a Compose issue.
v

Vadim Kapustin

05/31/2021, 11:33 AM
To reproduce this error in a newly created Compose project, just add the following code:
abstract class AbstractB<Type>(d: Type) : AbstractA<Int, Type>(d) {
    override fun test(key: Int): Type {
        return super.test(key)
    }
}

abstract class AbstractA<Type1, Type2>(var d: Type2) {
    open fun test(key: Type1): Type2 = d
}
This code worked with Compose 0.4.0-build190 and Kotlin 1.4.32, but with Compose 0.4.0-build198 and Kotlin 1.4.32 we have compiler error
🎉 2
j

jim

05/31/2021, 1:15 PM
You both are amazing! Thanks for the repro. Looks like a bug in the upstream compiler that is only hit as part of the Compose code path. Debugging it now!
a

Antoine Lamy

06/10/2021, 8:24 PM
Any update on this? Facing the same issue.
j

jim

06/10/2021, 8:56 PM
Yeah, I already fixed it in master. You can use the latest binaries published by Jetbrains which already have the fix, or wait until the next Google release goes out for Android. I think the Google release may be delayed by an additional week more than normal due to some reasons around late landing changes.
a

Antoine Lamy

06/10/2021, 8:59 PM
The latest compose binaries using the
org.jetbrains.compose
dependency?
j

jim

06/10/2021, 10:37 PM
yeah, afaik that should work now
are you still seeing issues there?
t

Thomas

06/15/2021, 5:43 PM
I can confirm that the latest Jetbrains build fixes the issue. Thanks a lot!