Skip to content

Commit c832d87

Browse files
committed
Convert subclasses of complex to complex
1 parent 7d5fb53 commit c832d87

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,10 @@ private PComplex createComplex(Object cls, double real, double imaginary) {
376376

377377
private PComplex createComplex(Object cls, PComplex value) {
378378
if (isPrimitiveProfile.profileClass(cls, PythonBuiltinClassType.PComplex)) {
379-
return value;
379+
if (isPrimitiveProfile.profileObject(value, PythonBuiltinClassType.PComplex)) {
380+
return value;
381+
}
382+
return factory().createComplex(value.getReal(), value.getImag());
380383
}
381384
return factory().createComplex(cls, value.getReal(), value.getImag());
382385
}

0 commit comments

Comments
 (0)