Skip to content
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

Java: support abstract return types #224

Merged
merged 5 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,642 changes: 1,321 additions & 1,321 deletions package-lock.json

Large diffs are not rendered by default.

1,282 changes: 641 additions & 641 deletions packages/codemaker/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/jsii-build-tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/jsii-calc-base-of-base/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"name": "VeryBaseProps",
"properties": [
{
"abstract": true,
"name": "foo",
"type": {
"fqn": "@scope/jsii-calc-base-of-base.Very"
Expand All @@ -67,5 +68,5 @@
}
},
"version": "0.7.4",
"fingerprint": "xM+yEz06NDR7n4G5n4VDoITs275dSqMhFDXgKOErl/M="
"fingerprint": "uxjBWk0nRDSHNR2FL01kRusKUoxa53smUFsizIJYBSs="
}
3 changes: 2 additions & 1 deletion packages/jsii-calc-base/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"name": "BaseProps",
"properties": [
{
"abstract": true,
"name": "bar",
"type": {
"primitive": "string"
Expand All @@ -100,5 +101,5 @@
}
},
"version": "0.7.4",
"fingerprint": "/t6/DercTjOI1TLjj3MowD7pZkpm70sJQdeKwQMpa9M="
"fingerprint": "6NsGM++itCYmctZJdOp8kPJ3CfBnajQ78wNpY+EwZIQ="
}
9 changes: 8 additions & 1 deletion packages/jsii-calc-lib/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"kind": "interface",
"methods": [
{
"abstract": true,
"docs": {
"comment": "Say hello!"
},
Expand All @@ -123,6 +124,7 @@
"name": "MyFirstStruct",
"properties": [
{
"abstract": true,
"docs": {
"comment": "An awesome number value"
},
Expand All @@ -132,6 +134,7 @@
}
},
{
"abstract": true,
"docs": {
"comment": "A string value"
},
Expand All @@ -141,6 +144,7 @@
}
},
{
"abstract": true,
"name": "firstOptional",
"type": {
"collection": {
Expand Down Expand Up @@ -250,6 +254,7 @@
"name": "StructWithOnlyOptionals",
"properties": [
{
"abstract": true,
"docs": {
"comment": "The first optional!"
},
Expand All @@ -260,13 +265,15 @@
}
},
{
"abstract": true,
"name": "optional2",
"type": {
"optional": true,
"primitive": "number"
}
},
{
"abstract": true,
"name": "optional3",
"type": {
"optional": true,
Expand Down Expand Up @@ -317,5 +324,5 @@
}
},
"version": "0.7.4",
"fingerprint": "dGLkY7rPKJjBMLQCOCj5AXR3Q1+cZcoiazcIhDUV++8="
"fingerprint": "PD1bhVhBjZ0dNrD8K4FK6RT+W5RhpkTEJDml/OiM7Ws="
}
52 changes: 52 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,4 +813,56 @@ export namespace InterfaceInNamespaceIncludesClasses {
*/
export interface InterfaceWithOptionalMethodArguments {
hello(arg1: string, arg2?: number): void
}

/**
* awslabs/jsii#220
* Abstract return type
*/

export interface InterfaceImplementedByAbstractClass {
readonly propFromInterface: string;
}

export abstract class AbstractClassBase {
public abstract readonly abstractProperty: string;
}

export abstract class AbstractClass extends AbstractClassBase implements InterfaceImplementedByAbstractClass {
public nonAbstractMethod() {
return 42;
}

public abstract abstractMethod(name: string): string;

public get propFromInterface() {
return 'propFromInterfaceValue';
}
}

class ConcreteClass extends AbstractClass {
public abstractMethod(name: string) {
return `Hello, ${name}!!`;
}

public get abstractProperty() {
return 'Hello, dude!';
}
}


export class AbstractClassReturner {
public giveMeAbstract(): AbstractClass {
return new ConcreteClass();
}

public giveMeInterface(): InterfaceImplementedByAbstractClass {
return new ConcreteClass();
}

public get returnAbstractFromProperty(): AbstractClassBase {
return {
abstractProperty: 'hello-abstract-property'
}
}
}
Loading