@@ -84,6 +84,27 @@ class PythonFunctionTests: XCTestCase {
84
84
XCTAssertEqual ( printOutput, " Class Dynamically Created! " )
85
85
}
86
86
87
+ // There is a build error where passing a simple `PythonClass.Members`
88
+ // literal makes the literal's type ambiguous. It is confused with
89
+ // `[String: PythonObject]`. To fix this error, we add a
90
+ // `@_disfavoredOverload` attribute to the more specific initializer.
91
+ func testPythonClassInitializer( ) {
92
+ guard canUsePythonFunction else {
93
+ return
94
+ }
95
+
96
+ let MyClass = PythonClass (
97
+ " MyClass " ,
98
+ superclasses: [ Python . object] ,
99
+ members: [
100
+ " memberName " : " memberValue " ,
101
+ ]
102
+ ) . pythonObject
103
+
104
+ let memberValue = MyClass ( ) . memberName
105
+ XCTAssertEqual ( String ( memberValue) , " memberValue " )
106
+ }
107
+
87
108
func testPythonClassInheritance( ) {
88
109
guard canUsePythonFunction else {
89
110
return
@@ -106,7 +127,7 @@ class PythonFunctionTests: XCTestCase {
106
127
helloOutput = String ( message)
107
128
108
129
// Conventional `super` syntax causes problems; use this instead.
109
- Python . Exception. __init__ ( self , message)
130
+ Python . Exception. __init__ ( ` self` , message)
110
131
return Python . None
111
132
} ,
112
133
@@ -130,7 +151,7 @@ class PythonFunctionTests: XCTestCase {
130
151
`self`. int_param = params [ 2 ]
131
152
132
153
// Conventional `super` syntax causes problems; use this instead.
133
- HelloException . __init__ ( self , message)
154
+ HelloException . __init__ ( ` self` , message)
134
155
return Python . None
135
156
} ,
136
157
0 commit comments