Skip to content

Start implementing nominal type resolution for jextract-swift#4

Merged
ktoso merged 6 commits into
swiftlang:mainfrom
DougGregor:jextract-nominal-type-resolution
Sep 27, 2024
Merged

Start implementing nominal type resolution for jextract-swift#4
ktoso merged 6 commits into
swiftlang:mainfrom
DougGregor:jextract-nominal-type-resolution

Conversation

@DougGregor
Copy link
Copy Markdown
Member

Introduce a basic implementation that can resolve the names of nominal types within a given module, including nested types and extensions of types. Use this to enable translating the members of extensions of types into members of the resulting Java class. It will also (eventually) allow us to cross-reference uses of Swift types within other Swift types.

Switch the representation of the imported types from a flat list over to
a dictionary mapping from the Swift name to the imported type. We need
this so that we can find information about the Swift type when it is
referenced elsewhere in the syntax tree, such as extensions or uses of
that type in other function signatures.

While here, stop recording intermediate results within the visitor
itself. Instead, keep a reference to the full translator and record
results there incrementally. This will become more important when we
start handling extensions.
Implement rudimentary name lookup and extension binding for nominal type
names so we can resolve Swift type names within a module.
Use the new nominal type resolution functionality within jextract-swift
to resolve extensions to their corresponding nominal types, so that
members of those extensions show up as member of the resulting Java
class.
Copy link
Copy Markdown
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Very nice, lgtm

Comment thread Sources/JExtractSwift/NominalTypeResolution.swift Outdated
_ resolution: NominalTypeResolution,
name: String,
fileID: String = #fileID,
fileParh: String = #filePath,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

small typo

Suggested change
fileParh: String = #filePath,
filePath: String = #filePath,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixing the typo separately :)

@ktoso ktoso merged commit 82749b1 into swiftlang:main Sep 27, 2024
@DougGregor DougGregor deleted the jextract-nominal-type-resolution branch September 27, 2024 16:09
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