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

Add knit directive to handle types marked with @_spi #184

Merged
merged 1 commit into from
Aug 12, 2024
Merged

Conversation

skorulis-ap
Copy link
Collaborator

@skorulis-ap skorulis-ap commented Aug 2, 2024

This is to handle the case where a type is public with an @_spi modifier. The generated resolver needs to also be marked with the same @_spi modifier. I used knit directives to supply this information as the parser doesn't know about the original type.

This is a fairly rare case that happened to come up ideally we should support it.

Example error when trying to use @_spi(Testing) protocol MySPIType inside DI:

Generated/KnitDITypeSafety: error: cannot use protocol 'MySPIType' here; it is SPI

public func mySPIType(file: StaticString = #fileID, function: StaticString = #function, line: UInt = #line) -> MySPIType {

@skorulis-ap skorulis-ap marked this pull request as ready for review August 2, 2024 03:36
@skorulis-ap skorulis-ap requested a review from bradfol August 2, 2024 03:36
Copy link
Collaborator

@bradfol bradfol left a comment

Choose a reason for hiding this comment

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

Thanks!


// Only 1 SPI is supported, the second will overwrite the first
XCTAssertEqual(
try parse("// @knit @_spi(First) @_spi(Second)"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should produce an IDE error here

@skorulis-ap skorulis-ap merged commit c8786c6 into main Aug 12, 2024
1 check passed
@skorulis-ap skorulis-ap deleted the skorulis/spi branch August 12, 2024 03:40
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