-
Notifications
You must be signed in to change notification settings - Fork 245
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
fix(jsii): unable to use type from dependencies' submodules #1557
fix(jsii): unable to use type from dependencies' submodules #1557
Conversation
When referring to a type defined in a submodule of a dependency (but not using the "inline `namespace`" syntax style), the `jsii` compiler failed to account for the namespace segment and generated an incorrect `fqn`, leading to a type resolution error failing the compilation. This adds a pass in the compiler to gather submodule layout from dependencies and correctly register them in the compilation context, so correct `fqn` are emitted. Additionally, this highlighted an issue where namespaces defined using the "inline `namespace`" syntax style would not be registered in the `this._submodules` set, causing them to not always be properly accounted for (depending on how the `TypeChecker` would represent them). New types have been introduced in `@scope/jsii-calc-lib` and `jsii-calc` to verify that the compiler produces reasonable output. Those will be leveraged in new compliance tests in a subsequent PR, as some outstanding code-generation issues come in the way of these tests.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
…-package-submodule-reference-building
And of course the Python generated code won't load because it lacks necessary |
Adds a `submodules` property on the `Assembly` structure, and carry it forward in the `dependencyClosure`, so the information can later be used to improve code generation for languages such as Python where the submodule structure is modeled as first-class entity that needs to be propertly dealt with. It can also help with properly adjusting the submodule names so they look more "native" in target languages, without facing problems when trying to generate type names in dependent packages. The forwarding of dependent submodules is not exercized in the current regression test suite because of a pair of other bugs (#1528, #1557) that need to be addressed before the generated Python code can successfully load. The last of those PRs to be merged will incldude the necessary test coverage.
Adds a `submodules` property on the `Assembly` structure, and carry it forward in the `dependencyClosure`, so the information can later be used to improve code generation for languages such as Python where the submodule structure is modeled as first-class entity that needs to be propertly dealt with. It can also help with properly adjusting the submodule names so they look more "native" in target languages, without facing problems when trying to generate type names in dependent packages. The forwarding of dependent submodules is not exercized in the current regression test suite because of a pair of other bugs (#1528, #1557) that need to be addressed before the generated Python code can successfully load. The last of those PRs to be merged will incldude the necessary test coverage. This change is necessary for these PRs to be able to fix their respective issues.
…-package-submodule-reference-building
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
Commit Message
fix(jsii): unable to use type from dependencies' submodules (#1557)
When referring to a type defined in a submodule of a dependency (but
not using the "inline
namespace
" syntax style), thejsii
compilerfailed to account for the namespace segment and generated an incorrect
fqn
, leading to a type resolution error failing the compilation.This adds a pass in the compiler to gather submodule layout from
dependencies and correctly register them in the compilation context, so
correct
fqn
are emitted.New types have been introduced in
@scope/jsii-calc-lib
andjsii-calc
to verify that the compiler produces reasonable output. Those will be
leveraged in new compliance tests in a subsequent PR, as some
outstanding code-generation issues come in the way of these tests.
End Commit Message
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.