jacodb icon indicating copy to clipboard operation
jacodb copied to clipboard

IllegalArgumentException during extracting type arguments for the superinterface of the "kotlin.text.RegexKt$fromInt$1$1" class

Open Damtev opened this issue 3 years ago • 1 comments

Steps to reproduce:

  • Add the kotlin-1.7.21 dependency to the analyzing classpath
  • Get a type for the kotlin.text.RegexKt$fromInt$1$1 class
  • Take its super interface
  • Extract type arguments for this super interface

Possible code:

classpath.findClass("kotlin.text.RegexKt\$fromInt\$1\$1").toType().interfaces.single().typeArguments

Expected behavior:

  • Extracting type arguments is successful

Actual behavior:

  • java.lang.IllegalArgumentException: Incorrect parameters specified for class java.lang.Enum: expected 1 found 0 occurs

The error's stack trace:

Exception in thread "main" java.lang.IllegalArgumentException: Incorrect parameters specified for class java.lang.Enum: expected 1 found 0
	at org.jacodb.impl.types.substition.JcSubstitutorKt.substitute(JcSubstitutor.kt:60)
	at org.jacodb.impl.types.JcClassTypeImpl.<init>(JcClassTypeImpl.kt:47)
	at org.jacodb.impl.types.JcTypeBindingsKt.typeOf(JcTypeBindings.kt:47)
	at org.jacodb.impl.types.JcTypeBindingsKt.typeOf$default(JcTypeBindings.kt:36)
	at org.jacodb.impl.types.TypeParametersKt.asJcDeclaration(TypeParameters.kt:70)
	at org.jacodb.impl.types.JcTypeBindingsKt.typeOf(JcTypeBindings.kt:70)
	at org.jacodb.impl.types.JcTypeBindingsKt.typeOf$default(JcTypeBindings.kt:36)
	at org.jacodb.impl.types.JcClassTypeImpl.getTypeArguments(JcClassTypeImpl.kt:81)
	at org.jacodb.typesolver.table.OCanrenTableKt.toJvmType(OCanrenTable.kt:86)
	at org.jacodb.typesolver.table.OCanrenTableKt.toJvmDeclaration(OCanrenTable.kt:77)
	at org.jacodb.typesolver.ClassesTableSerializerKt.makeClassesTable(ClassesTableSerializer.kt:222)
	at org.jacodb.typesolver.ClassesTableSerializerKt.main(ClassesTableSerializer.kt:208)
	at org.jacodb.typesolver.ClassesTableSerializerKt.main(ClassesTableSerializer.kt)

Damtev avatar May 10 '23 13:05 Damtev

There is still another way to reproduce this error:

 (classpath.findClass("kotlin.text.RegexKt\$fromInt\$1\$1").toType().interfaces.single().typeArguments.first() as JcTypeVariable).bounds

Stacktrace:

java.lang.IllegalArgumentException: Incorrect parameters specified for class java.lang.Enum: expected 1 found 0
	at org.jacodb.impl.types.substition.JcSubstitutorKt.substitute(JcSubstitutor.kt:62)
	at org.jacodb.impl.types.JcClassTypeImpl.<init>(JcClassTypeImpl.kt:51)
	at org.jacodb.impl.types.JcTypeBindingsKt.typeOf(JcTypeBindings.kt:46)
	at org.jacodb.impl.types.JcTypeBindingsKt.typeOf$default(JcTypeBindings.kt:36)
	at org.jacodb.impl.types.JcTypeVariableDeclarationImpl.getBounds(JcTypeBindings.kt:93)
	at org.jacodb.impl.types.JcTypeVariableImpl.getBounds(JcGenericTypes.kt:88)

Damtev avatar May 11 '23 09:05 Damtev