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

Update some impl IR APIs to more modern alternatives #734

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

ZacSweers
Copy link
Collaborator

Just a little cleanup to use more stable IR factory functions rather than direct impl types

Just a little cleanup to use more stable IR factory functions rather than direct impl types
varargElementType = IrDynamicTypeImpl(null, emptyList(), INVARIANT),
elements = contributedModules
valueArgument = irVararg(
elementType = pluginContext.irBuiltIns.kClassClass.starProjectedType,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a change from before, but I think this is more correct (Array<KClass<*>>) as dynamic is only really intended for JS targets iirc

Copy link
Member

Choose a reason for hiding this comment

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

What do you mean by this being a change from before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Before it was surprisingly the kotlin dynamic type, which I suspect was for lack of a better star alternative: https://kotlinlang.org/docs/dynamic-type.html

Copy link
Member

Choose a reason for hiding this comment

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

The dynamic type is not supported in code targeting the JVM. - mildly concerning :D, apparently it works though 😆. Good catch.

Comment on lines +56 to +57
pluginContext.irBuiltIns.createIrBuilder(declaration.symbol)
.generateDaggerAnnotation(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Creating an IR builder exposes more factory extension functions, including some of the ones used below

Copy link
Member

@JoelWilcox JoelWilcox Jul 31, 2023

Choose a reason for hiding this comment

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

Do we need to add any followup build() equivalent calls for the IrBuilder? Seems like the answer is no but just wanted to verify

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not as far as I know, it's more of a context thing than a true builder

Comment on lines +292 to +294
// These are always IrExpression instances too
values = varargArguments.flatMap { it.elements }
.filterIsInstance<IrExpression>()
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure this is guaranteed? Wondering why the extension function enforces IrExpressions when the impl class doesn't

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah if you look at the impl that's all it allows. My guess is it's a bit of a marker interface tomfoolery

varargElementType = IrDynamicTypeImpl(null, emptyList(), INVARIANT),
elements = contributedModules
valueArgument = irVararg(
elementType = pluginContext.irBuiltIns.kClassClass.starProjectedType,
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean by this being a change from before?

Comment on lines +56 to +57
pluginContext.irBuiltIns.createIrBuilder(declaration.symbol)
.generateDaggerAnnotation(
Copy link
Member

@JoelWilcox JoelWilcox Jul 31, 2023

Choose a reason for hiding this comment

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

Do we need to add any followup build() equivalent calls for the IrBuilder? Seems like the answer is no but just wanted to verify

@JoelWilcox JoelWilcox merged commit b96be8e into square:main Aug 1, 2023
19 checks passed
@ZacSweers ZacSweers deleted the z/updateIrApis branch August 1, 2023 02:38
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.

2 participants