-
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
kernel: return type for unexported types #345
Comments
An issue implementing this might be that the kernel does not have type information on unexported types, so it will only have:
And it for sure cannot return |
I reckon https://github.com/awslabs/jsii/blob/0301e305aab027f6350b3051a5d2b08b6fe7cbb5/packages/jsii-kernel/lib/kernel.ts#L964 should be changed so it accepts to return the current runtime type if it is assignable to the requested type. That would widely increase the scope of what can be down-casted in languages like Java. |
When passing references across the JSII language boundary, the static return type of a method is used instead of the runtime type of the object if they are not the same, even if they are compatible. This causes issues that make it impossible to up-cast from methods such as `IConstruct.findChild` that return a super-class that is expected to be up-casted to it's known dynamic type. Fixes #345
When passing references across the JSII language boundary, the static return type of a method is used instead of the runtime type of the object if they are not the same, even if they are compatible. This causes issues that make it impossible to up-cast from methods such as `IConstruct.findChild` that return a super-class that is expected to be up-casted to it's known dynamic type. Fixes #345
### Bug Fixes * remove use of private API ([#351](#351)) ([874cbac](874cbac)), closes [#350](#350) * **jsii-dotnet-runtime:** Fix EPIPE on Windows. ([1d7cc8b](1d7cc8b)), closes [#341](#341) * **jsii-dotnet-runtime:** Redirect to STDERR. ([e20f401](e20f401)) * **kernel:** Improve tagged type of wire values ([#346](#346)) ([8ea39ac](8ea39ac)), closes [#345](#345) ### Features * **jsii:** support multiple class declaration sites ([#348](#348)) ([4ecf28c](4ecf28c)) * Generate NuGet symbol and source packages ([#243](#243)) ([aafd405](aafd405))
### Bug Fixes * remove use of private API ([#351](#351)) ([874cbac](874cbac)), closes [#350](#350) * **jsii-dotnet-runtime:** Fix EPIPE on Windows. ([1d7cc8b](1d7cc8b)), closes [#341](#341) * **jsii-dotnet-runtime:** Redirect to STDERR. ([e20f401](e20f401)) * **kernel:** Improve tagged type of wire values ([#346](#346)) ([8ea39ac](8ea39ac)), closes [#345](#345) ### Features * **jsii:** support multiple class declaration sites ([#348](#348)) ([4ecf28c](4ecf28c)) * Generate NuGet symbol and source packages ([#243](#243)) ([aafd405](aafd405))
Someone reported a failing case over email, where we were returning a
Construct
to Java, which should have been a particular L1 class.Key insight: the type we construct a proxy for depends on the requested type. Compliance test:
Given the same object instance:
Constructors.makeClass()
should return a proxy object forInbetweenClass
.Constructors.makeInterface()
should return a proxy object forIPublicInterface
.Given:
PrivateClass
)PublicClass
vs.IPublicInterface
)We should be returning the most specific type on the inheritance path between actual and requested that is itself
exported
.The text was updated successfully, but these errors were encountered: