-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kernel): Correctly return instances of un-exported types (#321)
When an un-exported type that extends an exported type is returned with an interface as the declared type, the JSII kernel used to return a ref with the FQN of the exported supertype, instead of correctly wrapping the instance in a proxy of the interface type as it should have. --- Adds a test that covers the behavior of the JSII runtimes when a method is declared to return an interface type, and returns an instance of a private (un-exported) type that implements the interface while extending an exported type. This has been seen to cause issues in the Java runtime, for example, as the JSII kernel will return an ObjID with a type fragment that refers to the exported super-class, and not the interface type. --- Fixes #302
- Loading branch information
1 parent
44c3b9b
commit 9c59acc
Showing
20 changed files
with
458 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExportedBaseClass.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
[JsiiClass(typeof(ExportedBaseClass), "jsii-calc.ExportedBaseClass", "[{\"name\":\"success\",\"type\":{\"primitive\":\"boolean\"}}]")] | ||
public class ExportedBaseClass : DeputyBase | ||
{ | ||
public ExportedBaseClass(bool success): base(new DeputyProps(new object[]{success})) | ||
{ | ||
} | ||
|
||
protected ExportedBaseClass(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
protected ExportedBaseClass(DeputyProps props): base(props) | ||
{ | ||
} | ||
|
||
[JsiiProperty("success", "{\"primitive\":\"boolean\"}")] | ||
public virtual bool Success | ||
{ | ||
get => GetInstanceProperty<bool>(); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIPrivatelyImplemented.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
[JsiiInterface(typeof(IIPrivatelyImplemented), "jsii-calc.IPrivatelyImplemented")] | ||
public interface IIPrivatelyImplemented | ||
{ | ||
[JsiiProperty("success", "{\"primitive\":\"boolean\"}")] | ||
bool Success | ||
{ | ||
get; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...s.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IPrivatelyImplementedProxy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
[JsiiTypeProxy(typeof(IIPrivatelyImplemented), "jsii-calc.IPrivatelyImplemented")] | ||
internal sealed class IPrivatelyImplementedProxy : DeputyBase, IIPrivatelyImplemented | ||
{ | ||
private IPrivatelyImplementedProxy(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
[JsiiProperty("success", "{\"primitive\":\"boolean\"}")] | ||
public bool Success | ||
{ | ||
get => GetInstanceProperty<bool>(); | ||
} | ||
} | ||
} |
Oops, something went wrong.
9c59acc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes #320, not #302.