Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.MessageCollectorAccess
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarAdapter
import org.jetbrains.kotlin.name.ClassId

Expand All @@ -26,6 +27,7 @@ public class ChameleonCompilerPluginRegistrar : CompilerPluginRegistrar() {
)
val themeVariantClassId = ClassId.fromString(themeVariantEnumString)

@OptIn(MessageCollectorAccess::class)
val messageCollector = configuration[CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE]

FirExtensionRegistrarAdapter.registerExtension(ChameleonFirExtensionRegistrar)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/RedundantBurstAnnotation.kt:7:1: error: `@Burst` annotation is redundant on classes annotated with `@Chameleon`.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoots
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.MessageCollectorAccess
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarAdapter
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
Expand Down Expand Up @@ -40,15 +41,13 @@ private class ChameleonExtensionRegistrarConfigurator(

FirExtensionRegistrarAdapter.registerExtension(ChameleonFirExtensionRegistrar)

@OptIn(MessageCollectorAccess::class)
IrGenerationExtension.registerExtension(
ChameleonIrGenerationExtension(
chameleonAnnotationId = ClassIds.Chameleon.Annotation,
snapshotFunctionId = snapshotFunctionString.toMemberCallableId(),
themeVariantEnumId = ClassId.fromString(themeVariantEnumString),
messageCollector = configuration.get(
CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY,
MessageCollector.NONE,
),
messageCollector = configuration[CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE],
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.reactivecircus.kstreamlined.gradle.internal

import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import dev.zacsweers.metro.gradle.DelicateMetroGradleApi
import dev.zacsweers.metro.gradle.ExperimentalMetroGradleApi
import dev.zacsweers.metro.gradle.MetroPluginExtension
import org.gradle.api.DefaultTask
import org.gradle.api.Project
Expand All @@ -23,6 +24,8 @@ internal fun Project.configureMetro() {
pluginManager.apply("dev.zacsweers.metro")
extensions.configure(MetroPluginExtension::class.java) {
it.generateContributionProviders.set(true)
@OptIn(ExperimentalMetroGradleApi::class)
it.generateClassesInIr.set(false) // TODO re-enable once supported by RouteBinding
if (providers.gradleProperty("enableMetroCompilerReports").orNull == "true") {
it.reportsDestination.set(layout.buildDirectory.dir("metro_reports"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.MessageCollectorAccess
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarAdapter

public class RouteBindingCompilerPluginRegistrar : CompilerPluginRegistrar() {
Expand All @@ -15,6 +16,7 @@ public class RouteBindingCompilerPluginRegistrar : CompilerPluginRegistrar() {
override val supportsK2: Boolean get() = true

override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
@OptIn(MessageCollectorAccess::class)
val messageCollector = configuration[CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE]

FirExtensionRegistrarAdapter.registerExtension(RouteBindingFirExtensionRegistrar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package io.github.reactivecircus.routebinding.compiler.fir.diagnostics

import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckers
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirSimpleFunctionChecker
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirNamedFunctionChecker
import org.jetbrains.kotlin.fir.analysis.extensions.FirAdditionalCheckersExtension

internal class RouteBindingFirAdditionalCheckersExtension(
session: FirSession,
) : FirAdditionalCheckersExtension(session) {
override val declarationCheckers: DeclarationCheckers = object : DeclarationCheckers() {
override val simpleFunctionCheckers: Set<FirSimpleFunctionChecker>
override val namedFunctionCheckers: Set<FirNamedFunctionChecker>
get() = setOf(RouteBindingFunctionChecker)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirSimpleFunctionChecker
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirNamedFunctionChecker
import org.jetbrains.kotlin.fir.declarations.FirFunction
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
Expand All @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.fir.types.isSubtypeOf
import org.jetbrains.kotlin.fir.types.renderReadable
import org.jetbrains.kotlin.name.Name

internal object RouteBindingFunctionChecker : FirSimpleFunctionChecker(MppCheckerKind.Common) {
internal object RouteBindingFunctionChecker : FirNamedFunctionChecker(MppCheckerKind.Common) {
context(context: CheckerContext, reporter: DiagnosticReporter)
override fun check(declaration: FirNamedFunction) {
if (!declaration.hasAnnotation(ClassIds.RouteBinding.Annotation, context.session)) return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/DuplicateParameterType.kt:13:5: error: `@RouteBinding` function `DuplicateNavKeySubtype` has multiple parameters of type `NavKey`. Only one parameter per supported type is allowed.

/DuplicateParameterType.kt:22:5: error: `@RouteBinding` function `DuplicateSharedTransitionScope` has multiple parameters of type `SharedTransitionScope`. Only one parameter per supported type is allowed.

/DuplicateParameterType.kt:31:5: error: `@RouteBinding` function `DuplicateNavBackStack` has multiple parameters of type `NavBackStack<NavKey>`. Only one parameter per supported type is allowed.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/NonComposableFunction.kt:5:14: error: `@RouteBinding` function `DummyScreen` must be a `@Composable` function.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/NonObjectMetadataProvider.kt:10:53: error: `ClassMetadataProvider` is not an object declaration. `metadataProvider` must be an `object` implementing `RouteMetadataProvider`.

/NonObjectMetadataProvider.kt:15:53: error: `RouteMetadataProvider` is not an object declaration. `metadataProvider` must be an `object` implementing `RouteMetadataProvider`.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/NonTopLevelFunction.kt:8:18: error: `@RouteBinding` function `DummyScreen` must be top level function.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/PrivateFunction.kt:7:1: error: `@RouteBinding` function `DummyScreen` cannot be private. Change the visibility of the function to internal instead.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/PublicFunction.kt:7:1: warning: `@RouteBinding` function `DummyScreen` does not need to be visible to other modules. Consider changing its visibility to internal.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/RouteParameterTypeMismatch.kt:19:5: error: Parameter type `AnotherRoute` does not match `@RouteBinding` route type `DummyRoute` in function `MismatchedValueParam`.

/RouteParameterTypeMismatch.kt:26:9: error: Parameter type `AnotherRoute` does not match `@RouteBinding` route type `DummyRoute` in function `MismatchedContextParam`.

/RouteParameterTypeMismatch.kt:33:14: error: Parameter type `AnotherRoute` does not match `@RouteBinding` route type `DummyRoute` in function `MismatchedReceiver`.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/UnsupportedContextParameter.kt:7:55: error: Context parameter `foo` of `@RouteBinding` function `Foo` has unsupported type `String`. Supported types are:
• `SharedTransitionScope`
• `NavBackStack<NavKey>`
• subtype of `NavKey`

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/UnsupportedReceiverType.kt:6:14: error: Extension receiver of `@RouteBinding` function `UnsupportedReceiverScreen` has unsupported type `String`. Supported types are:
• `SharedTransitionScope`
• `NavBackStack<NavKey>`
• subtype of `NavKey`

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/UnsupportedValueParameter.kt:8:5: error: Parameter `foo` of `@RouteBinding` function `FooScreen` has unsupported type `String`. Supported types are:
• `SharedTransitionScope`
• `NavBackStack<NavKey>`
• subtype of `NavKey`
• anything with a default value

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FILE: /FooScreen_NavEntryInstaller.kt
}

}
FILE: metro/hints/fooScreen_NavEntryInstallerAppScope.kt
FILE: metro/hints/fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun dev_zacsweers_metro_AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class FooScreen_NavEntryInstaller : NavEntryInstaller {
@Binds
@IntoSet
@CallableMetadata(callableName = "bindIntoSetAsNavEntryInstaller", propertyName = "", startOffset = -1, endOffset = -1)
abstract fun bindIntoSetAsNavEntryInstaller_intoset(instance: FooScreen_NavEntryInstaller): NavEntryInstaller
fun bindIntoSetAsNavEntryInstaller_intoset(instance: FooScreen_NavEntryInstaller): NavEntryInstaller {
return error(message = "Never called")
}

}

Expand Down Expand Up @@ -94,10 +96,10 @@ fun box(): String {
return "OK"
}

// FILE: fooScreen_NavEntryInstallerAppScope.kt
// FILE: fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@Deprecated(message = "This synthesized declaration should not be used directly", level = DeprecationLevel.HIDDEN)
fun AppScope(contributed: FooScreen_NavEntryInstaller) {
fun dev_zacsweers_metro_AppScope(contributed: FooScreen_NavEntryInstaller) {
return error(message = "Never called")
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FILE: /FooScreen_NavEntryInstaller.kt
}

}
FILE: metro/hints/fooScreen_NavEntryInstallerAppScope.kt
FILE: metro/hints/fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun dev_zacsweers_metro_AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class FooScreen_NavEntryInstaller : NavEntryInstaller {
@Binds
@IntoSet
@CallableMetadata(callableName = "bindIntoSetAsNavEntryInstaller", propertyName = "", startOffset = -1, endOffset = -1)
abstract fun bindIntoSetAsNavEntryInstaller_intoset(instance: FooScreen_NavEntryInstaller): NavEntryInstaller
fun bindIntoSetAsNavEntryInstaller_intoset(instance: FooScreen_NavEntryInstaller): NavEntryInstaller {
return error(message = "Never called")
}

}

Expand Down Expand Up @@ -94,10 +96,10 @@ fun box(): String {
return "OK"
}

// FILE: fooScreen_NavEntryInstallerAppScope.kt
// FILE: fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@Deprecated(message = "This synthesized declaration should not be used directly", level = DeprecationLevel.HIDDEN)
fun AppScope(contributed: FooScreen_NavEntryInstaller) {
fun dev_zacsweers_metro_AppScope(contributed: FooScreen_NavEntryInstaller) {
return error(message = "Never called")
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FILE: /FooScreen_NavEntryInstaller.kt
}

}
FILE: metro/hints/fooScreen_NavEntryInstallerAppScope.kt
FILE: metro/hints/fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun dev_zacsweers_metro_AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class FooScreen_NavEntryInstaller : NavEntryInstaller {
@Binds
@IntoSet
@CallableMetadata(callableName = "bindIntoSetAsNavEntryInstaller", propertyName = "", startOffset = -1, endOffset = -1)
abstract fun bindIntoSetAsNavEntryInstaller_intoset(instance: FooScreen_NavEntryInstaller): NavEntryInstaller
fun bindIntoSetAsNavEntryInstaller_intoset(instance: FooScreen_NavEntryInstaller): NavEntryInstaller {
return error(message = "Never called")
}

}

Expand Down Expand Up @@ -94,10 +96,10 @@ fun box(): String {
return "OK"
}

// FILE: fooScreen_NavEntryInstallerAppScope.kt
// FILE: fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@Deprecated(message = "This synthesized declaration should not be used directly", level = DeprecationLevel.HIDDEN)
fun AppScope(contributed: FooScreen_NavEntryInstaller) {
fun dev_zacsweers_metro_AppScope(contributed: FooScreen_NavEntryInstaller) {
return error(message = "Never called")
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ FILE: /FooScreen_NavEntryInstaller.kt
}

}
FILE: metro/hints/fooScreen_NavEntryInstallerAppScope.kt
FILE: metro/hints/fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun dev_zacsweers_metro_AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class FooScreen_NavEntryInstaller : NavEntryInstaller {
@Binds
@IntoSet
@CallableMetadata(callableName = "bindIntoSetAsNavEntryInstaller", propertyName = "", startOffset = -1, endOffset = -1)
abstract fun bindIntoSetAsNavEntryInstaller_intoset(instance: FooScreen_NavEntryInstaller): NavEntryInstaller
fun bindIntoSetAsNavEntryInstaller_intoset(instance: FooScreen_NavEntryInstaller): NavEntryInstaller {
return error(message = "Never called")
}

}

Expand Down Expand Up @@ -107,10 +109,10 @@ fun box(): String {
return "OK"
}

// FILE: fooScreen_NavEntryInstallerAppScope.kt
// FILE: fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@Deprecated(message = "This synthesized declaration should not be used directly", level = DeprecationLevel.HIDDEN)
fun AppScope(contributed: FooScreen_NavEntryInstaller) {
fun dev_zacsweers_metro_AppScope(contributed: FooScreen_NavEntryInstaller) {
return error(message = "Never called")
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FILE: /FooScreen_NavEntryInstaller.kt
}

}
FILE: metro/hints/fooScreen_NavEntryInstallerAppScope.kt
FILE: metro/hints/fooScreen_NavEntryInstallerDev_zacsweers_metro_AppScope.kt
package metro.hints

@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final fun dev_zacsweers_metro_AppScope(contributed: R|FooScreen_NavEntryInstaller|): R|kotlin/Unit|
Loading