when <updating to 0.15.1> I'm getting a failure - ...
# konsist
p
when updating to 0.15.1 I'm getting a failure - see the thread for a stack trace
Copy code
com.lemonappdev.konsist.core.exception.KoInternalException: Failed to parse Kotlin file: /Users/piotr/repos/github-workflows-kt/buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle/kotlin/dsl/accessors/_76a779107637b25b34866585d88a55c4/Accessorsdfahp28yse49o5zwao0rw07vs.kt
	at app//com.lemonappdev.konsist.core.util.KotlinFileParser.getKtFile(KotlinFileParser.kt:49)
	at app//com.lemonappdev.konsist.core.util.KotlinFileParser.getKoFile(KotlinFileParser.kt:54)
	at app//com.lemonappdev.konsist.core.ext.FileExtKt.toKoFile(FileExt.kt:12)
	at app//com.lemonappdev.konsist.core.provider.util.KoFileDeclarationProvider$parseKotlinFile$2$1.invokeSuspend(KoFileDeclarationProvider.kt:80)
	at app//kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at app//kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at app//kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
	at app//kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
	at app//kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
	at app//kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
	at app//kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
	at app//kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)
	Suppressed: com.lemonappdev.konsist.core.exception.KoInternalException: Failed to parse Kotlin file: /Users/piotr/repos/github-workflows-kt/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/ClassNaming.kt
		... 12 more
	Caused by: java.lang.ClassCastException: class org.jetbrains.kotlin.idea.KotlinFileType cannot be cast to class org.jetbrains.kotlin.com.intellij.openapi.fileTypes.FileType (org.jetbrains.kotlin.idea.KotlinFileType and org.jetbrains.kotlin.com.intellij.openapi.fileTypes.FileType are in unnamed module of loader 'app')
		at com.lemonappdev.konsist.core.util.KotlinFileParser.getKtFile(KotlinFileParser.kt:45)
		... 11 more
	Suppressed: com.lemonappdev.konsist.core.exception.KoInternalException: Failed to parse Kotlin file: /Users/piotr/repos/github-workflows-kt/buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle/kotlin/dsl/accessors/_76a779107637b25b34866585d88a55c4/Accessorsb13nju9doius8kxwhlptqirtr.kt
		... 12 more
it goes on, but some of the parts are repeated
on 0.15.0 it works the same way
i
Can you please attach one or more files that can't be parsed?
p
looking at
Suppressed: com.lemonappdev.konsist.core.exception.KoInternalException: Failed to parse Kotlin file: /Users/piotr/repos/github-workflows-kt/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/ClassNaming.kt
, it's this file: https://github.com/typesafegithub/github-workflows-kt/blob/main/action-binding-gen[…]thub/workflows/actionbindinggenerator/generation/ClassNaming.kt
there's some non-determinism: I checked the latest failure (Renovate periodically rebases the PR on top of newest
main
), and this time (see the Gradle build scan) the problematic files are: • lots of failures on Gradle-generated Kotlin DSL accessors, like:
Failed to parse Kotlin file: /home/runner/work/github-workflows-kt/github-workflows-kt/buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle/kotlin/dsl/accessors/_76a779107637b25b34866585d88a55c4/Accessors46nwrg1rs44ofdqpi7vyy3pfc.kt
• issues with the code actually in the repo: ◦
Failed to parse Kotlin file: /home/runner/work/github-workflows-kt/github-workflows-kt/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt
Failed to parse Kotlin file: /home/runner/work/github-workflows-kt/github-workflows-kt/automation/code-generator/src/main/kotlin/io/github/typesafegithub/workflows/dsl/expressions/GenerateEventPayloads.kt
Failed to parse Kotlin file: /home/runner/work/github-workflows-kt/github-workflows-kt/automation/code-generator/src/test/kotlin/io/github/typesafegithub/workflows/codegenerator/AddDeprecationInfoTest.kt
Failed to parse Kotlin file: /home/runner/work/github-workflows-kt/github-workflows-kt/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt
◦ there's more
also this issue appears in multiple levels of the stack trace:
Caused by: java.lang.ClassCastException: class org.jetbrains.kotlin.idea.KotlinFileType cannot be cast to class <http://org.jetbrains.kotlin.com|org.jetbrains.kotlin.com>.intellij.openapi.fileTypes.FileType (org.jetbrains.kotlin.idea.KotlinFileType and <http://org.jetbrains.kotlin.com|org.jetbrains.kotlin.com>.intellij.openapi.fileTypes.FileType are in unnamed module of loader 'app')
example contents of `/Users/piotr/repos/github-workflows-kt/buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle/kotlin/dsl/accessors/_76a779107637b25b34866585d88a55c4/Accessorse6ex1mefr8h1znr2ivlnwcx4n.kt`:
Copy code
/*
 * Copyright 2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      <http://www.apache.org/licenses/LICENSE-2.0>
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@file:Suppress(
    "unused",
    "nothing_to_inline",
    "useless_cast",
    "unchecked_cast",
    "extension_shadowed_by_member",
    "redundant_projection",
    "RemoveRedundantBackticks",
    "ObjectPropertyName",
    "deprecation"
)
@file:org.gradle.api.Generated

/* ktlint-disable */

package gradle.kotlin.dsl.accessors._76a779107637b25b34866585d88a55c4


import org.gradle.api.Action
import org.gradle.api.Incubating
import org.gradle.api.NamedDomainObjectProvider
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ConfigurablePublishArtifact
import org.gradle.api.artifacts.ConfigurationContainer
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.DependencyConstraint
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.artifacts.PublishArtifact
import org.gradle.api.artifacts.dsl.ArtifactHandler
import org.gradle.api.artifacts.dsl.DependencyConstraintHandler
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderConvertible
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider

import org.gradle.kotlin.dsl.*
import org.gradle.kotlin.dsl.accessors.runtime.*


/**
 * Retrieves the [ext][org.gradle.api.plugins.ExtraPropertiesExtension] extension.
 */
internal
val org.gradle.api.artifacts.VersionCatalogsExtension.`ext`: org.gradle.api.plugins.ExtraPropertiesExtension get() =
    (this as org.gradle.api.plugins.ExtensionAware).extensions.getByName("ext") as org.gradle.api.plugins.ExtraPropertiesExtension

/**
 * Configures the [ext][org.gradle.api.plugins.ExtraPropertiesExtension] extension.
 */
internal
fun org.gradle.api.artifacts.VersionCatalogsExtension.`ext`(configure: Action<org.gradle.api.plugins.ExtraPropertiesExtension>): Unit =
    (this as org.gradle.api.plugins.ExtensionAware).extensions.configure("ext", configure)
I think this sheds some light - the API Konsist is trying to use is somehow unavailable in runtime
this is the source of
LightVirtualFile
https://github.com/JetBrains/intellij-community/blob/ca977bb49429f31956cb37a3844fb[…]m/core-api/src/com/intellij/testFramework/LightVirtualFile.java, but I think it has been bundled with the Kotlin compiler in a way that the Java package is changed. This version of the file doesn't contain any overload of the constructor that accepts
KotlinFileType
(what Konsist is trying to use)
ah,
KotlinFileType
inherits from
LanguageFileType
inherit from
FileType
I'm going to leave it here, too much internals for a quick investigation 😄 let me know if you need me to check something in case it doesn't reproduce for you
👍 1
i
We are not able to reproduce this issue. Looks like dependency clash. Can you perhaps share your project? I would appreciate working sample to reproduce e.g. strip all of the code leaving Konsist test, one failing class and dependencies (minimal gradle build config - mostly used dependencies).
p
it reproduces in this PR: https://github.com/typesafegithub/github-workflows-kt/pull/1339 so you can clone the repo and check out the branch. It will be hard for me to create a minimal reproducer in the following days, and this issue is also non-deterministic
👍 1