-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rosetta): Python translation for
implements
is wrong (#3280)
For Python, interface implementation needs to be written as `@jsii.implements(Iface)`. Also add a check that people don't put functions in object literals. Fixes aws/aws-cdk#17928 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
- Loading branch information
Showing
8 changed files
with
195 additions
and
7 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
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
7 changes: 7 additions & 0 deletions
7
packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.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,7 @@ | ||
class MyClass : IResolvable | ||
{ | ||
public object Resolve() | ||
{ | ||
return 42; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.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,5 @@ | ||
public class MyClass implements IResolvable { | ||
public Object resolve() { | ||
return 42; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.py
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,4 @@ | ||
@jsii.implements(IResolvable) | ||
class MyClass: | ||
def resolve(self): | ||
return 42 |
12 changes: 12 additions & 0 deletions
12
packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.ts
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,12 @@ | ||
/// !hide | ||
/// fake-from-jsii | ||
interface IResolvable { | ||
resolve(): any; | ||
} | ||
/// !show | ||
|
||
class MyClass implements IResolvable { | ||
public resolve(): any { | ||
return 42; | ||
} | ||
} |