Fix heavy integer parsing in FunctionN class factory
#KT-7924 Fixed
This commit is contained in:
+11
-6
@@ -43,12 +43,7 @@ public class BuiltInFictitiousFunctionClassFactory(
|
||||
val prefix = kind.classNamePrefix
|
||||
if (!className.startsWith(prefix)) continue
|
||||
|
||||
val arity = try {
|
||||
className.substring(prefix.length()).toInt()
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
continue
|
||||
}
|
||||
val arity = toInt(className.substring(prefix.length())) ?: continue
|
||||
|
||||
// TODO: validate arity, should be <= 255 for functions, <= 254 for members/extensions
|
||||
return KindWithArity(kind, arity)
|
||||
@@ -56,6 +51,16 @@ public class BuiltInFictitiousFunctionClassFactory(
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun toInt(s: String): Int? {
|
||||
var result = 0
|
||||
for (c in s) {
|
||||
val d = c - '0'
|
||||
if (d !in 0..9) return null
|
||||
result = result * 10 + d
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
override fun createClass(classId: ClassId): ClassDescriptor? {
|
||||
|
||||
Reference in New Issue
Block a user