When adding the line
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings
to a fresh clone the example Fabric Kotlin mod (here), the following errors are seen:
e: C:\[...]\MinimalImportError\src\main\kotlin\net\fabricmc\example\ExampleMod.kt: (3, 32): Qualified name must be a '.'-separated identifier list
e: C:\[...]\MinimalImportError\src\main\kotlin\net\fabricmc\example\ExampleMod.kt: (3, 39): Unresolved reference: builder
kotlin.code.style=official
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# Check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.7
loader_version=0.10.8
#Fabric api
fabric_version=0.28.1+1.16
loom_version=0.5-SNAPSHOT
# Mod Properties
mod_version = 1.0.0
maven_group = net.minimalproblem
archives_base_name = minimal-import-error-mod
# Kotlin
kotlin_version=1.4.0
fabric_kotlin_version=1.4.0+build.1
src/main/kotlin/net/fabricmc/example/ExampleMod.kt file and add the following as line 3:import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings
runClient or compileKotlin Gradle task (the compile task is a dependency of the run task, so either will fail in the same place).This isn't really a bug. object is a keyword in Kotlin, so it needs to be escaped with backticks:
import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings
IDEA should do this automatically for you as well.
Juuz's solution there is the right way to work around that.
Thank you. I could not for the life of me figure out the problem nor find a solution. I did not know about backticks. I will look up more information about this syntax.
Most helpful comment
This isn't really a bug.
objectis a keyword in Kotlin, so it needs to be escaped with backticks:IDEA should do this automatically for you as well.