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

Support default arguments #36

Merged
merged 1 commit into from
Oct 23, 2024
Merged

Conversation

swankjesse
Copy link
Collaborator

Also don't generate anything that'll immediately be ignored. This creates more confusion than clarity.

Closes: #18

Also don't generate anything that'll immediately be ignored.
This creates more confusion than clarity.

Closes: #18
@oldergod
Copy link

I love this feature!

@@ -58,5 +61,13 @@ internal fun IrPluginContext.allPossibleArguments(
val referenceClass = referenceClass(classId)?.owner ?: return null
if (!referenceClass.isEnumClass) return null
val enumEntries = referenceClass.declarations.filterIsInstance<IrEnumEntry>()
return enumEntries.map { Argument(parameter, parameter.type, it) }
val defaultValueSymbol = (parameter.defaultValue?.expression as? IrGetEnumValue)?.symbol
Copy link
Collaborator

Choose a reason for hiding this comment

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

We talked about erroring if the default value is anything other than a constant enum value. Otherwise you could silently refactor out common defaults into a helper function (or something) and silently break the specialization.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lemme do that in a follow-up!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#37

@swankjesse swankjesse merged commit 85a9ca4 into main Oct 23, 2024
1 check passed
@swankjesse swankjesse deleted the jwilson.1022.default_specialization branch October 23, 2024 17:43
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.

Build awesome IDE integration
4 participants