Skip to content

Commit 73fc824

Browse files
committed
Fix fuzzing when collection with generics is this object
1 parent 8a42887 commit 73fc824

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzing/JavaLanguage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private fun toFuzzerType(type: Type): FuzzedType {
118118
}
119119
FuzzedType(classId)
120120
}
121-
is Class<*> -> FuzzedType(type.id)
121+
is Class<*> -> FuzzedType(type.id, type.typeParameters.map { toFuzzerType(it) })
122122
else -> error("Unknown type: $type")
123123
}
124124
}

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzing/providers/Collections.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class MapValueProvider(
8383
yield(FuzzedType(java.util.TreeMap::class.id, listOf(keyGeneric, valueGeneric)))
8484
}
8585
}
86-
else -> yieldConcreteClass(type)
86+
else -> yieldConcreteClass(FuzzedType(type.classId, listOf(keyGeneric, valueGeneric)))
8787
}
8888
}
8989

@@ -126,7 +126,7 @@ class ListSetValueProvider(
126126
yield(FuzzedType(java.util.TreeSet::class.id, listOf(generic)))
127127
}
128128
}
129-
else -> yieldConcreteClass(type)
129+
else -> yieldConcreteClass(FuzzedType(type.classId, listOf(generic)))
130130
}
131131
}
132132

@@ -154,7 +154,7 @@ abstract class CollectionValueProvider(
154154
}
155155

156156
protected suspend fun SequenceScope<FuzzedType>.yieldConcreteClass(type: FuzzedType) {
157-
if (with (type.classId) { !isAbstract && isPublic && isStatic }) {
157+
if (with (type.classId) { !isAbstract && isPublic && (!isInner || isStatic) }) {
158158
val emptyConstructor = type.classId.allConstructors.find { it.parameters.isEmpty() }
159159
if (emptyConstructor != null && emptyConstructor.isPublic) {
160160
yield(type)

0 commit comments

Comments
 (0)