Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin 2.0.0 #1036

Merged
merged 31 commits into from
May 30, 2024
Merged

Kotlin 2.0.0 #1036

merged 31 commits into from
May 30, 2024

Conversation

SimonMarquis
Copy link
Contributor

@SimonMarquis SimonMarquis commented Nov 16, 2023

@SimonMarquis
Copy link
Contributor Author

e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering (link)
e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering

File being compiled: /home/runner/work/nowinandroid/nowinandroid/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/Scrollbar.kt
The root cause java.lang.ClassCastException was thrown at: org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.transform(InlineCallableReferenceToLambda.kt:73)
	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:253)
	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:236)
	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:65)
	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:52)
	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:38)
	at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147)
	at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94)
	at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:30)
	at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:17)
	at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147)
	at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94)
	at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:43)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeLowerings(JvmIrCodegenFactory.kt:[347](https://github.com/android/nowinandroid/actions/runs/6888047868/job/18736301855?pr=1036#step:8:348))
	at org.jetbrains.kotlin.codegen.CodegenFactory.generateModule(CodegenFactory.kt:44)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModuleInFrontendIRMode(JvmIrCodegenFactory.kt:378)
	at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.CompilerPipelineKt.generateCodeFromIr(compilerPipeline.kt:259)
	at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.CompilerPipelineKt.compileModulesUsingFrontendIrAndLightTree(compilerPipeline.kt:150)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:156)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1508)
	at jdk.internal.reflect.GeneratedMethodAccessor93.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:[360](https://github.com/android/nowinandroid/actions/runs/6888047868/job/18736301855?pr=1036#step:8:361))
	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:712)
	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:[399](https://github.com/android/nowinandroid/actions/runs/6888047868/job/18736301855?pr=1036#step:8:400))
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ClassCastException: class org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl cannot be cast to class org.jetbrains.kotlin.ir.expressions.IrFunctionReference (org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl and org.jetbrains.kotlin.ir.expressions.IrFunctionReference are in unnamed module of loader 'app')
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.transform(InlineCallableReferenceToLambda.kt:73)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitFunctionAccess(InlineCallableReferenceToLambda.kt:64)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitFunctionAccess(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitCall(IrElementVisitor.kt:140)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitCall(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitCall(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.kt:26)
	at org.jetbrains.kotlin.ir.expressions.IrBranch.acceptChildren(IrBranch.kt:34)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:56)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitBranch(IrElementVisitor.kt:263)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitBranch(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitBranch(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.expressions.IrBranch.accept(IrBranch.kt:27)
	at org.jetbrains.kotlin.ir.expressions.IrWhen.acceptChildren(IrWhen.kt:29)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:56)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitExpression(IrElementVisitor.kt:83)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitExpression(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitExpression(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitWhen(IrElementVisitor.kt:260)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitWhen(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitWhen(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.expressions.IrWhen.accept(IrWhen.kt:26)
	at org.jetbrains.kotlin.ir.expressions.IrBlockBody.acceptChildren(IrBlockBody.kt:28)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:56)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitBody(IrElementVisitor.kt:86)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitBody(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitBody(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitBlockBody(IrElementVisitor.kt:92)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitBlockBody(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitBlockBody(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBlockBody.kt:25)
	at org.jetbrains.kotlin.ir.declarations.IrFunction.acceptChildren(IrFunction.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:56)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitDeclaration(IrElementVisitor.kt:23)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitDeclaration(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitDeclaration(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitFunction(IrElementVisitor.kt:38)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitFunction(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitFunction(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitSimpleFunction(IrElementVisitor.kt:65)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitSimpleFunction(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitSimpleFunction(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:37)
	at org.jetbrains.kotlin.ir.declarations.IrClass.acceptChildren(IrClass.kt:88)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:56)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitDeclaration(IrElementVisitor.kt:23)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitDeclaration(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitDeclaration(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitClass(IrElementVisitor.kt:29)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitClass(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitClass(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:84)
	at org.jetbrains.kotlin.ir.declarations.IrFile.acceptChildren(IrFile.kt:37)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:56)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitElement(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitPackageFragment(IrElementVisitor.kt:74)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitPackageFragment(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitPackageFragment(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitFile(IrElementVisitor.kt:80)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitFile(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaVisitor.visitFile(InlineCallableReferenceToLambda.kt:54)
	at org.jetbrains.kotlin.ir.declarations.IrFile.accept(IrFile.kt:31)
	at org.jetbrains.kotlin.backend.jvm.lower.InlineCallableReferenceToLambdaPhase.lower(InlineCallableReferenceToLambda.kt:49)
	at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$makeIrFilePhase$2.invoke(PhaseBuilders.kt:136)
	at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$makeIrFilePhase$2.invoke(PhaseBuilders.kt:128)
	at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$createSimpleNamedCompilerPhase$1.phaseBody(PhaseBuilders.kt:72)
	at org.jetbrains.kotlin.backend.common.phaser.SimpleNamedCompilerPhase.phaseBody(CompilerPhase.kt:207)
	at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94)
	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:62)
	... 36 more

@SimonMarquis
Copy link
Contributor Author

SimonMarquis commented Nov 28, 2023

@SimonMarquis
Copy link
Contributor Author

Flaky emulators on CI 😢

@SimonMarquis
Copy link
Contributor Author

K2 Supported! 🙌

Add (kotlin.experimental.tryK2=true) in gradle.properties to display stats.

##### 'kotlin.experimental.tryK2' results #####
:app:compileDemoReleaseKotlin: 2.0 language version
:core:analytics:compileDemoReleaseKotlin: 2.0 language version
:core:common:compileDemoReleaseKotlin: 2.0 language version
:core:data:compileDemoReleaseKotlin: 2.0 language version
:core:database:compileDemoReleaseKotlin: 2.0 language version
:core:datastore-proto:compileDemoReleaseKotlin: 2.0 language version
:core:datastore:compileDemoReleaseKotlin: 2.0 language version
:core:designsystem:compileDemoReleaseKotlin: 2.0 language version
:core:domain:compileDemoReleaseKotlin: 2.0 language version
:core:model:compileKotlin: 2.0 language version
:core:network:compileDemoReleaseKotlin: 2.0 language version
:core:notifications:compileDemoReleaseKotlin: 2.0 language version
:core:ui:compileDemoReleaseKotlin: 2.0 language version
:feature:bookmarks:compileDemoReleaseKotlin: 2.0 language version
:feature:foryou:compileDemoReleaseKotlin: 2.0 language version
:feature:interests:compileDemoReleaseKotlin: 2.0 language version
:feature:search:compileDemoReleaseKotlin: 2.0 language version
:feature:settings:compileDemoReleaseKotlin: 2.0 language version
:feature:topic:compileDemoReleaseKotlin: 2.0 language version
:sync:work:compileDemoReleaseKotlin: 2.0 language version
##### 100% (20/20) tasks have been compiled with Kotlin 2.0 #####

@lihenggui
Copy link
Contributor

ping @SimonMarquis Kotlin 2.0.0 released.

We could follow this article to remove some deprecated fields.

https://medium.com/@kacper.wojciechowski/kotlin-2-0-android-project-migration-guide-b1234fbbff65

@SimonMarquis
Copy link
Contributor Author

Thanks @lihenggui, I'm in the process of updating multiple repos. I'll update this one soon and remove experimental KSP2/K2UAST.

@SimonMarquis SimonMarquis changed the title 🚧 Kotlin 2.0.0 Kotlin 2.0.0 May 22, 2024
@SimonMarquis SimonMarquis marked this pull request as ready for review May 22, 2024 18:46
@SimonMarquis
Copy link
Contributor Author

🎉 I feel like this PR is now ready to be reviewed!

@dturner (or anyone else merging this) don't forget to squash/merge to avoid the long list of changes.

Copy link
Member

@bentrengrove bentrengrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice work

@bentrengrove bentrengrove merged commit 85129e4 into android:main May 30, 2024
4 checks passed
dturner added a commit that referenced this pull request May 30, 2024
* main:
  Kotlin 2.0.0 (#1036)
  Update app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt
  🤖 Updates screenshots
  🤖 Updates baselines for Dependency Guard
  Update material3-adaptive to beta01
  🤖 Updates baselines for Dependency Guard
  Bump androidxComposeAlpha from 1.7.0-alpha08 to 1.7.0-beta01
  🤖 Updates baselines for Dependency Guard
  Bump hilt from 2.51 to 2.51.1
  Add NavigationSuiteScaffold
  Fix state loss with workaround

Change-Id: I14d7294fe93f68b9aca6df9bf7bf87ff95583581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants