@@ -84,6 +84,27 @@ class PythonFunctionTests: XCTestCase {
8484 XCTAssertEqual ( printOutput, " Class Dynamically Created! " )
8585 }
8686
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+
87108 func testPythonClassInheritance( ) {
88109 guard canUsePythonFunction else {
89110 return
@@ -106,7 +127,7 @@ class PythonFunctionTests: XCTestCase {
106127 helloOutput = String ( message)
107128
108129 // Conventional `super` syntax causes problems; use this instead.
109- Python . Exception. __init__ ( self , message)
130+ Python . Exception. __init__ ( ` self` , message)
110131 return Python . None
111132 } ,
112133
@@ -130,7 +151,7 @@ class PythonFunctionTests: XCTestCase {
130151 `self`. int_param = params [ 2 ]
131152
132153 // Conventional `super` syntax causes problems; use this instead.
133- HelloException . __init__ ( self , message)
154+ HelloException . __init__ ( ` self` , message)
134155 return Python . None
135156 } ,
136157
0 commit comments