@@ -3,17 +3,20 @@ package org.usvm.machine.types
33import org.jacodb.ets.model.EtsAliasType
44import org.jacodb.ets.model.EtsAnyType
55import org.jacodb.ets.model.EtsArrayType
6+ import org.jacodb.ets.model.EtsBooleanLiteralType
67import org.jacodb.ets.model.EtsBooleanType
78import org.jacodb.ets.model.EtsClassType
89import org.jacodb.ets.model.EtsFunctionType
910import org.jacodb.ets.model.EtsIntersectionType
1011import org.jacodb.ets.model.EtsLiteralType
1112import org.jacodb.ets.model.EtsNeverType
1213import org.jacodb.ets.model.EtsNullType
14+ import org.jacodb.ets.model.EtsNumberLiteralType
1315import org.jacodb.ets.model.EtsNumberType
1416import org.jacodb.ets.model.EtsPrimitiveType
1517import org.jacodb.ets.model.EtsRefType
1618import org.jacodb.ets.model.EtsScene
19+ import org.jacodb.ets.model.EtsStringLiteralType
1720import org.jacodb.ets.model.EtsStringType
1821import org.jacodb.ets.model.EtsTupleType
1922import org.jacodb.ets.model.EtsType
@@ -91,11 +94,10 @@ class TsTypeSystem(
9194 if (unwrappedSupertype is EtsPrimitiveType && unwrappedType is EtsPrimitiveType ) {
9295 if (unwrappedType is EtsLiteralType ) {
9396 // Literal types are subtypes of their base primitive (e.g., 'foo' <: string).
94- return when (unwrappedType.literalTypeName) {
95- " String" -> unwrappedSupertype is EtsStringType
96- " Number" -> unwrappedSupertype is EtsNumberType
97- " Boolean" -> unwrappedSupertype is EtsBooleanType
98- else -> error(" Unexpected literal type name ${unwrappedType.literalTypeName} " )
97+ return when (unwrappedType) {
98+ is EtsStringLiteralType -> unwrappedSupertype is EtsStringType
99+ is EtsNumberLiteralType -> unwrappedSupertype is EtsNumberType
100+ is EtsBooleanLiteralType -> unwrappedSupertype is EtsBooleanType
99101 }
100102 }
101103
@@ -224,7 +226,8 @@ class TsTypeSystem(
224226 is EtsUnionType -> true // unions can always drop a branch
225227 is EtsIntersectionType -> true // intersections can always add a constraint
226228 is EtsAnyType ,
227- is EtsUnknownType -> true // top types can always have subtypes
229+ is EtsUnknownType ,
230+ -> true // top types can always have subtypes
228231 else -> false
229232 }
230233 }
@@ -239,7 +242,8 @@ class TsTypeSystem(
239242 is EtsNumberType ,
240243 is EtsStringType ,
241244 is EtsBooleanType ,
242- is EtsLiteralType -> true // primitives/literals always final
245+ is EtsLiteralType ,
246+ -> true // primitives/literals always final
243247 is EtsClassType -> false
244248 else -> false // others can always be specialized
245249 }
@@ -250,11 +254,13 @@ class TsTypeSystem(
250254 return when (t) {
251255 is EtsNeverType -> false // no runtime value
252256 is EtsAnyType ,
253- is EtsUnknownType -> true // may represent some value
257+ is EtsUnknownType ,
258+ -> true // may represent some value
254259 is EtsLiteralType ,
255260 is EtsNullType ,
256261 is EtsUndefinedType ,
257- is EtsPrimitiveType -> true // literals/primitives have values
262+ is EtsPrimitiveType ,
263+ -> true // literals/primitives have values
258264 is EtsUnionType -> t.types.any { isInstantiable(it) } // union has some branch value
259265 is EtsIntersectionType -> t.types.all { isInstantiable(it) } // intersection if all parts have values
260266 is EtsArrayType -> isInstantiable(t.elementType) // array if elements instantiable
@@ -270,7 +276,8 @@ class TsTypeSystem(
270276 return when (t) {
271277 is EtsPrimitiveType -> emptySequence()
272278 is EtsAnyType ,
273- is EtsUnknownType ->
279+ is EtsUnknownType ,
280+ ->
274281 scene.projectAndSdkClasses
275282 .asSequence()
276283 .map { it.type }
@@ -296,7 +303,8 @@ class TsTypeSystem(
296303 }
297304
298305 is EtsUnclearRefType ,
299- is EtsClassType ->
306+ is EtsClassType ,
307+ ->
300308 if ((t as ? EtsClassType )?.signature == EtsHierarchy .OBJECT_CLASS .signature) { // TODO change it
301309 scene.projectAndSdkClasses.asSequence().map { it.type } + EtsStringType + EtsAnyType
302310 } else {
0 commit comments