diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TSetFromMap.java b/classlib/src/main/java/org/teavm/classlib/java/util/TSetFromMap.java
index f2b943ca8..1ceb3ce9e 100644
--- a/classlib/src/main/java/org/teavm/classlib/java/util/TSetFromMap.java
+++ b/classlib/src/main/java/org/teavm/classlib/java/util/TSetFromMap.java
@@ -46,7 +46,7 @@ public class TSetFromMap<E> extends TAbstractSet<E> {
 
     @Override
     public boolean add(E e) {
-        return map.put(e, TBoolean.TRUE) != null;
+        return map.put(e, TBoolean.TRUE) == null;
     }
 
     @Override