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

fix: match behavioral interface to 'I'-prefix #271

Merged
merged 1 commit into from
Oct 23, 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
16 changes: 8 additions & 8 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,17 @@ export class GiveMeStructs {
}
}

export interface IInterfaceWithProperties {
export interface InterfaceWithProperties {
readonly readOnlyString: string;
readWriteString: string;
}

export interface IInterfaceWithPropertiesExtension extends IInterfaceWithProperties {
export interface InterfaceWithPropertiesExtension extends InterfaceWithProperties {
foo: number;
}

export class UsesInterfaceWithProperties {
constructor(public readonly obj: IInterfaceWithProperties) {
constructor(public readonly obj: InterfaceWithProperties) {

}

Expand All @@ -543,7 +543,7 @@ export class UsesInterfaceWithProperties {
return this.obj.readWriteString;
}

public readStringAndNumber(ext: IInterfaceWithPropertiesExtension) {
public readStringAndNumber(ext: InterfaceWithPropertiesExtension) {
return `base=${ext.readOnlyString} child=${ext.foo} keys=[${Object.keys(ext).join(',')}]`;
}
}
Expand Down Expand Up @@ -573,13 +573,13 @@ export class AllowedMethodNames {
}
}

export interface ReturnsNumber {
export interface IReturnsNumber {
obtainNumber(): Number;
readonly numberProp: Number;
}

export class OverrideReturnsObject {
public test(obj: ReturnsNumber) {
public test(obj: IReturnsNumber) {
return obj.obtainNumber().doubleValue + obj.numberProp.doubleValue;
}
}
Expand Down Expand Up @@ -832,7 +832,7 @@ export namespace InterfaceInNamespaceIncludesClasses {
* awslabs/jsii#175
* Interface proxies (and builders) do not respect optional arguments in methods
*/
export interface InterfaceWithOptionalMethodArguments {
export interface IInterfaceWithOptionalMethodArguments {
hello(arg1: string, arg2?: number): void
}

Expand Down Expand Up @@ -918,7 +918,7 @@ export class DoNotOverridePrivates {
/**
* Class that implements interface properties automatically, but using a private constructor
*/
export class ClassWithPrivateConstructorAndAutomaticProperties implements IInterfaceWithProperties {
export class ClassWithPrivateConstructorAndAutomaticProperties implements InterfaceWithProperties {
public static create(readOnlyString: string, readWriteString: string) {
return new ClassWithPrivateConstructorAndAutomaticProperties(readOnlyString, readWriteString);
}
Expand Down
188 changes: 94 additions & 94 deletions packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@
"fqn": "jsii-calc.ClassWithPrivateConstructorAndAutomaticProperties",
"interfaces": [
{
"fqn": "jsii-calc.IInterfaceWithProperties"
"fqn": "jsii-calc.InterfaceWithProperties"
}
],
"kind": "class",
Expand Down Expand Up @@ -1076,7 +1076,7 @@
"immutable": true,
"name": "readOnlyString",
"overrides": {
"fqn": "jsii-calc.IInterfaceWithProperties"
"fqn": "jsii-calc.InterfaceWithProperties"
},
"type": {
"primitive": "string"
Expand All @@ -1085,7 +1085,7 @@
{
"name": "readWriteString",
"overrides": {
"fqn": "jsii-calc.IInterfaceWithProperties"
"fqn": "jsii-calc.InterfaceWithProperties"
},
"type": {
"primitive": "string"
Expand Down Expand Up @@ -1498,50 +1498,35 @@
}
]
},
"jsii-calc.IInterfaceWithProperties": {
"jsii-calc.IInterfaceWithOptionalMethodArguments": {
"assembly": "jsii-calc",
"datatype": true,
"fqn": "jsii-calc.IInterfaceWithProperties",
"docs": {
"comment": "awslabs/jsii#175\nInterface proxies (and builders) do not respect optional arguments in methods"
},
"fqn": "jsii-calc.IInterfaceWithOptionalMethodArguments",
"kind": "interface",
"name": "IInterfaceWithProperties",
"properties": [
{
"abstract": true,
"immutable": true,
"name": "readOnlyString",
"type": {
"primitive": "string"
}
},
"methods": [
{
"abstract": true,
"name": "readWriteString",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.IInterfaceWithPropertiesExtension": {
"assembly": "jsii-calc",
"datatype": true,
"fqn": "jsii-calc.IInterfaceWithPropertiesExtension",
"interfaces": [
{
"fqn": "jsii-calc.IInterfaceWithProperties"
"name": "hello",
"parameters": [
{
"name": "arg1",
"type": {
"primitive": "string"
}
},
{
"name": "arg2",
"type": {
"optional": true,
"primitive": "number"
}
}
]
}
],
"kind": "interface",
"name": "IInterfaceWithPropertiesExtension",
"properties": [
{
"abstract": true,
"name": "foo",
"type": {
"primitive": "number"
}
}
]
"name": "IInterfaceWithOptionalMethodArguments"
},
"jsii-calc.IRandomNumberGenerator": {
"assembly": "jsii-calc",
Expand All @@ -1565,6 +1550,31 @@
],
"name": "IRandomNumberGenerator"
},
"jsii-calc.IReturnsNumber": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.IReturnsNumber",
"kind": "interface",
"methods": [
{
"abstract": true,
"name": "obtainNumber",
"returns": {
"primitive": "number"
}
}
],
"name": "IReturnsNumber",
"properties": [
{
"abstract": true,
"immutable": true,
"name": "numberProp",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.ImplictBaseOfBase": {
"assembly": "jsii-calc",
"datatype": true,
Expand Down Expand Up @@ -1659,35 +1669,50 @@
}
]
},
"jsii-calc.InterfaceWithOptionalMethodArguments": {
"jsii-calc.InterfaceWithProperties": {
"assembly": "jsii-calc",
"docs": {
"comment": "awslabs/jsii#175\nInterface proxies (and builders) do not respect optional arguments in methods"
},
"fqn": "jsii-calc.InterfaceWithOptionalMethodArguments",
"datatype": true,
"fqn": "jsii-calc.InterfaceWithProperties",
"kind": "interface",
"methods": [
"name": "InterfaceWithProperties",
"properties": [
{
"abstract": true,
"name": "hello",
"parameters": [
{
"name": "arg1",
"type": {
"primitive": "string"
}
},
{
"name": "arg2",
"type": {
"optional": true,
"primitive": "number"
}
}
]
"immutable": true,
"name": "readOnlyString",
"type": {
"primitive": "string"
}
},
{
"abstract": true,
"name": "readWriteString",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.InterfaceWithPropertiesExtension": {
"assembly": "jsii-calc",
"datatype": true,
"fqn": "jsii-calc.InterfaceWithPropertiesExtension",
"interfaces": [
{
"fqn": "jsii-calc.InterfaceWithProperties"
}
],
"name": "InterfaceWithOptionalMethodArguments"
"kind": "interface",
"name": "InterfaceWithPropertiesExtension",
"properties": [
{
"abstract": true,
"name": "foo",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.JSObjectLiteralForInterface": {
"assembly": "jsii-calc",
Expand Down Expand Up @@ -2380,7 +2405,7 @@
{
"name": "obj",
"type": {
"fqn": "jsii-calc.ReturnsNumber"
"fqn": "jsii-calc.IReturnsNumber"
}
}
],
Expand Down Expand Up @@ -2530,31 +2555,6 @@
}
]
},
"jsii-calc.ReturnsNumber": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.ReturnsNumber",
"kind": "interface",
"methods": [
{
"abstract": true,
"name": "obtainNumber",
"returns": {
"primitive": "number"
}
}
],
"name": "ReturnsNumber",
"properties": [
{
"abstract": true,
"immutable": true,
"name": "numberProp",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.RuntimeTypeChecking": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.RuntimeTypeChecking",
Expand Down Expand Up @@ -3087,7 +3087,7 @@
{
"name": "obj",
"type": {
"fqn": "jsii-calc.IInterfaceWithProperties"
"fqn": "jsii-calc.InterfaceWithProperties"
}
}
]
Expand All @@ -3106,7 +3106,7 @@
{
"name": "ext",
"type": {
"fqn": "jsii-calc.IInterfaceWithPropertiesExtension"
"fqn": "jsii-calc.InterfaceWithPropertiesExtension"
}
}
],
Expand Down Expand Up @@ -3135,7 +3135,7 @@
"immutable": true,
"name": "obj",
"type": {
"fqn": "jsii-calc.IInterfaceWithProperties"
"fqn": "jsii-calc.InterfaceWithProperties"
}
}
]
Expand Down Expand Up @@ -3401,5 +3401,5 @@
}
},
"version": "0.7.7",
"fingerprint": "vJH1gHlpRxKo77e0kE+6KATwgsZB0VpBcFEo/9OIG7Q="
"fingerprint": "ztjwo/sf4owA37SlePL0icwoE4gA3UJyvQ2Zl89FSco="
}
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public override string TheProperty
}
}

class InterfaceWithProperties : DeputyBase, IIInterfaceWithProperties
class InterfaceWithProperties : DeputyBase, IInterfaceWithProperties
{
string _x;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import software.amazon.jsii.tests.calculator.GiveMeStructs;
import software.amazon.jsii.tests.calculator.IFriendlier;
import software.amazon.jsii.tests.calculator.IFriendlyRandomGenerator;
import software.amazon.jsii.tests.calculator.IInterfaceWithProperties;
import software.amazon.jsii.tests.calculator.InterfaceWithProperties;
import software.amazon.jsii.tests.calculator.IRandomNumberGenerator;
import software.amazon.jsii.tests.calculator.InterfaceImplementedByAbstractClass;
import software.amazon.jsii.tests.calculator.JSObjectLiteralForInterface;
Expand Down Expand Up @@ -555,7 +555,7 @@ public void setTheProperty(String value) {

@Test
public void propertyOverrides_interfaces() {
IInterfaceWithProperties obj = new IInterfaceWithProperties() {
InterfaceWithProperties obj = new InterfaceWithProperties() {
private String x;

@Override
Expand All @@ -581,7 +581,7 @@ public void setReadWriteString(String value) {

@Test
public void interfaceBuilder() {
IInterfaceWithProperties obj = IInterfaceWithProperties.builder()
InterfaceWithProperties obj = InterfaceWithProperties.builder()
.withReadOnlyString("READ_ONLY")
.withReadWriteString("READ_WRITE")
.build();
Expand Down
Loading