-
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.
feat(jsii): Erase un-exported base classes instead of prohibiting tho…
…se (#425) When an exported class extends an un-exported class, merge the declarations of the un-exported base into the exported one, and replace the base class relationship with the base's own base (recursively until an exported base is found, or no further base class is declared - in which case the exported class will not have a base class at all). Declarations from the erased base class(es) will be ignored if there is another declaration with the same name and type in the exported type (or another erased base class that is closer to the exported type in the inheritance chain). Fixes #417
- Loading branch information
1 parent
9cfd867
commit d006f5c
Showing
20 changed files
with
534 additions
and
31 deletions.
There are no files selected for viewing
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,25 @@ | ||
// | ||
// Un-exported base classes are erased | ||
// https://github.com/awslabs/jsii/issues/417 | ||
// | ||
class JSII417PrivateRoot { | ||
public readonly hasRoot = true; | ||
} | ||
export class JSII417PublicBaseOfBase extends JSII417PrivateRoot { | ||
public static makeInstance(): JSII417PublicBaseOfBase { | ||
return new JSII417PrivateBase("TEST"); | ||
} | ||
public foo() { return; } | ||
} | ||
class JSII417PrivateBase extends JSII417PublicBaseOfBase { | ||
constructor(protected readonly property: string) { | ||
super(); | ||
} | ||
public bar() { return; } | ||
} | ||
export class JSII417Derived extends JSII417PrivateBase { | ||
public bar() { | ||
return super.bar(); | ||
} | ||
public baz() { return; } | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './calculator'; | ||
export * from './compliance'; | ||
export * from './documented'; | ||
export * from './erasures'; |
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
38 changes: 38 additions & 0 deletions
38
...on.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JSII417Derived.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,38 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
[JsiiClass(typeof(JSII417Derived), "jsii-calc.JSII417Derived", "[{\"name\":\"property\",\"type\":{\"primitive\":\"string\"}}]")] | ||
public class JSII417Derived : JSII417PublicBaseOfBase | ||
{ | ||
public JSII417Derived(string property): base(new DeputyProps(new object[]{property})) | ||
{ | ||
} | ||
|
||
protected JSII417Derived(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
protected JSII417Derived(DeputyProps props): base(props) | ||
{ | ||
} | ||
|
||
[JsiiProperty("property", "{\"primitive\":\"string\"}")] | ||
protected virtual string Property | ||
{ | ||
get => GetInstanceProperty<string>(); | ||
} | ||
|
||
[JsiiMethod("bar", null, "[]")] | ||
public virtual void Bar() | ||
{ | ||
InvokeInstanceVoidMethod(new object[]{}); | ||
} | ||
|
||
[JsiiMethod("baz", null, "[]")] | ||
public virtual void Baz() | ||
{ | ||
InvokeInstanceVoidMethod(new object[]{}); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...ests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JSII417PublicBaseOfBase.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,38 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
[JsiiClass(typeof(JSII417PublicBaseOfBase), "jsii-calc.JSII417PublicBaseOfBase", "[]")] | ||
public class JSII417PublicBaseOfBase : DeputyBase | ||
{ | ||
public JSII417PublicBaseOfBase(): base(new DeputyProps(new object[]{})) | ||
{ | ||
} | ||
|
||
protected JSII417PublicBaseOfBase(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
protected JSII417PublicBaseOfBase(DeputyProps props): base(props) | ||
{ | ||
} | ||
|
||
[JsiiProperty("hasRoot", "{\"primitive\":\"boolean\"}")] | ||
public virtual bool HasRoot | ||
{ | ||
get => GetInstanceProperty<bool>(); | ||
} | ||
|
||
[JsiiMethod("makeInstance", "{\"fqn\":\"jsii-calc.JSII417PublicBaseOfBase\"}", "[]")] | ||
public static JSII417PublicBaseOfBase MakeInstance() | ||
{ | ||
return InvokeStaticMethod<JSII417PublicBaseOfBase>(typeof(JSII417PublicBaseOfBase), new object[]{}); | ||
} | ||
|
||
[JsiiMethod("foo", null, "[]")] | ||
public virtual void Foo() | ||
{ | ||
InvokeInstanceVoidMethod(new object[]{}); | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...ed.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JSII417Derived.java
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,25 @@ | ||
package software.amazon.jsii.tests.calculator; | ||
|
||
@javax.annotation.Generated(value = "jsii-pacmak") | ||
@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.JSII417Derived") | ||
public class JSII417Derived extends software.amazon.jsii.tests.calculator.JSII417PublicBaseOfBase { | ||
protected JSII417Derived(final software.amazon.jsii.JsiiObject.InitializationMode mode) { | ||
super(mode); | ||
} | ||
public JSII417Derived(final java.lang.String property) { | ||
super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); | ||
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, java.util.stream.Stream.of(java.util.Objects.requireNonNull(property, "property is required")).toArray()); | ||
} | ||
|
||
public void bar() { | ||
this.jsiiCall("bar", Void.class); | ||
} | ||
|
||
public void baz() { | ||
this.jsiiCall("baz", Void.class); | ||
} | ||
|
||
protected java.lang.String getProperty() { | ||
return this.jsiiGet("property", java.lang.String.class); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...alc/java/src/main/java/software/amazon/jsii/tests/calculator/JSII417PublicBaseOfBase.java
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,25 @@ | ||
package software.amazon.jsii.tests.calculator; | ||
|
||
@javax.annotation.Generated(value = "jsii-pacmak") | ||
@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.JSII417PublicBaseOfBase") | ||
public class JSII417PublicBaseOfBase extends software.amazon.jsii.JsiiObject { | ||
protected JSII417PublicBaseOfBase(final software.amazon.jsii.JsiiObject.InitializationMode mode) { | ||
super(mode); | ||
} | ||
public JSII417PublicBaseOfBase() { | ||
super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); | ||
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); | ||
} | ||
|
||
public static software.amazon.jsii.tests.calculator.JSII417PublicBaseOfBase makeInstance() { | ||
return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JSII417PublicBaseOfBase.class, "makeInstance", software.amazon.jsii.tests.calculator.JSII417PublicBaseOfBase.class); | ||
} | ||
|
||
public void foo() { | ||
this.jsiiCall("foo", Void.class); | ||
} | ||
|
||
public java.lang.Boolean getHasRoot() { | ||
return this.jsiiGet("hasRoot", java.lang.Boolean.class); | ||
} | ||
} |
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
Oops, something went wrong.