diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
index bd39e944..9107cda6 100644
--- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
@@ -100,14 +100,16 @@ struct OverloadSortData
      * a OverloadData. This is done to express type dependencies that could
      * or could not appear in overloaded signatures not processed yet.
      */
-    void mapType(const QString &typeName)
+    int mapType(const QString &typeName)
     {
-        if (map.contains(typeName))
-            return;
-        map[typeName] = counter;
-        if (!reverseMap.contains(counter))
-            reverseMap[counter] = nullptr;
-        counter++;
+        auto it = map.find(typeName);
+        if (it == map.end()) {
+            it = map.insert(typeName, counter);
+            if (!reverseMap.contains(counter))
+                reverseMap[counter] = nullptr;
+            counter++;
+        }
+        return it.value();
     }
 
     void mapType(OverloadData *overloadData)
@@ -125,6 +127,18 @@ struct OverloadSortData
     QHash<int, OverloadData *> reverseMap;   // id -> OverloadData;
 };
 
+static void addPrimitiveConversion(Graph &graph,const OverloadSortData &s, const QString &target, const QString &convertible)
+{
+    const auto targetIt = s.map.find(target);
+    if (targetIt == s.map.end())
+        return;
+    const auto convertibleIt = s.map.find(convertible);
+    if (convertibleIt == s.map.end())
+        return;
+    graph.addEdge(targetIt.value(), convertibleIt.value());
+    qDebug() << __FUNCTION__ << target << convertible;
+}
+
 /**
  * Helper function that returns the name of a container get from containerType argument and
  * an instantiation taken either from an implicit conversion expressed by the function argument,
@@ -200,14 +214,12 @@ void OverloadData::sortNextOverloads()
 
     // Primitive types that are not int, long, short,
     // char and their respective unsigned counterparts.
-    QStringList nonIntegerPrimitives;
-    nonIntegerPrimitives << QLatin1String("float") << QLatin1String("double")
-        << QLatin1String("bool");
+    static QStringList const nonIntegerPrimitives{QLatin1String("float"), QLatin1String("double"),
+                                                  QLatin1String("bool")};
 
     // Signed integer primitive types.
-    QStringList signedIntegerPrimitives;
-    signedIntegerPrimitives << QLatin1String("int") << QLatin1String("short")
-       << QLatin1String("long");
+    static const QStringList signedIntegerPrimitives{QLatin1String("int"), QLatin1String("short"),
+                                                     QLatin1String("long")};
 
     // sort the children overloads
     for (OverloadData *ov : qAsConst(m_nextOverloadData))
@@ -425,9 +437,25 @@ void OverloadData::sortNextOverloads()
         }
     }
 
+    bool v = referenceFunction()->name() == QLatin1String("setAttribute");
+
+    if (v) {
+        qDebug() << __FUNCTION__ << referenceFunction();
+        for (auto f : m_overloads)
+            qDebug() << "  "  << f;
+        qDebug() << __FUNCTION__ << sortData.map;
+    }
+    addPrimitiveConversion(graph, sortData, QStringLiteral("double"), QStringLiteral("float"));
+    addPrimitiveConversion(graph, sortData, QStringLiteral("int"), QStringLiteral("unsigned int"));
+    addPrimitiveConversion(graph, sortData, QStringLiteral("unsigned long long"), QStringLiteral("unsigned int"));
+    addPrimitiveConversion(graph, sortData, QStringLiteral("unsigned long long"), QStringLiteral("int"));
+    addPrimitiveConversion(graph, sortData, QStringLiteral("long long"), QStringLiteral("int"));
+    addPrimitiveConversion(graph, sortData, QStringLiteral("double"), QStringLiteral("unsigned long long"));
+    addPrimitiveConversion(graph, sortData, QStringLiteral("double"), QStringLiteral("long long"));
+
     // sort the overloads topologically based on the dependency graph.
     const auto unmappedResult = graph.topologicalSort();
-    if (unmappedResult.isEmpty()) {
+    if (unmappedResult.isEmpty() || v) {
         QString funcName = referenceFunction()->name();
         if (referenceFunction()->ownerClass())
             funcName.prepend(referenceFunction()->ownerClass()->name() + QLatin1Char('.'));
@@ -438,7 +466,9 @@ void OverloadData::sortNextOverloads()
         for (auto it = sortData.map.cbegin(), end = sortData.map.cend(); it != end; ++it)
             nodeNames.insert(it.value(), it.key());
         graph.dumpDot(nodeNames, graphName);
-        qCWarning(lcShiboken).noquote() << qPrintable(msgCyclicDependency(funcName, graphName, involvedConversions));
+        qDebug() << graphName;
+        if (unmappedResult.isEmpty())
+            qCWarning(lcShiboken).noquote() << qPrintable(msgCyclicDependency(funcName, graphName, involvedConversions));
     }
 
     m_nextOverloadData.clear();
