-
Notifications
You must be signed in to change notification settings - Fork 0
§4. Same‐name declarations
Arno Dölinger edited this page Jun 30, 2026
·
2 revisions
Two declarations with the exact same name and parameter types in the same class are a Kotlin compile error — the type-checker sees both before the IR phase where Platform Weaver runs.
// Kotlin frontend duplicate error, Platform Weaver never even gets to run
@FabricOnly val configDir: String = "config/mod"
@PaperOnly val configDir: String = "plugins/Mod"This is intentional and will not be fixed — it's actually a feature.
If you need the same name on both platforms, that's a signal the concept belongs behind an interface. Define it once in shared code, implement it per platform:
// Shared. No annotation, compiled into every JAR
interface PlatformPaths {
val configDir: String
}
// Compiled into the Fabric JAR only:
@FabricOnly
object FabricPaths : PlatformPaths {
override val configDir = "config/mod"
}
// Compiled into the Paper JAR only:
@PaperOnly
object PaperPaths : PlatformPaths {
override val configDir = "plugins/Mod"
}Shared code talks to PlatformPaths. Each JAR ships exactly one implementation.
This same adapter idea is how you handle structural divergence with @Chameleon: normalize the differing platform data behind one small type, then let the shared code — and your chameleons — speak only to that.