Kotlin / dukat

Converter of <any kind of declarations> to Kotlin external declarations
557 stars 42 forks source link

Fix generation of descriptors when some type contains error. #518

Closed hwvenancio closed 1 year ago

hwvenancio commented 1 year ago

Summary

Fix generation of descriptors when some type contains error.

Steps to reproduce

Discovered errors while trying to convert vue 3.3.4. The steps to reproduce are the follwing:

git clone https://github.com/Kotlin/dukat.git
cd dukat
mkdir test-vue-conversion
cd test-vue-conversion
export PROJECT_HOME=$(pwd)
npm install vue@3.3.4
cd ..
./gradlew build :node-package:buildDistrib -x test
cd node-package/build/distrib/bin
node dukat-cli.js --descriptors -p dw -d $PROJECT_HOME/src/js/kotlin/ $PROJECT_HOME/node_modules/vue/dist/vue.d.ts

It crashes with the following exception:

Exception in thread "main" java.lang.IllegalStateException: Cannot serialize error type: [ERROR : Directive]
        at org.jetbrains.kotlin.serialization.SerializerExtension.serializeErrorType(SerializerExtension.kt:93)
        at org.jetbrains.kotlin.serialization.DescriptorSerializer.type$serialization(DescriptorSerializer.kt:553)
        at org.jetbrains.kotlin.serialization.DescriptorSerializer.typeArgument(DescriptorSerializer.kt:649)
        at org.jetbrains.kotlin.serialization.DescriptorSerializer.fillFromPossiblyInnerType(DescriptorSerializer.kt:620)
        at org.jetbrains.kotlin.serialization.DescriptorSerializer.type$serialization(DescriptorSerializer.kt:580)
        at org.jetbrains.kotlin.serialization.DescriptorSerializer.type$serialization(DescriptorSerializer.kt:602)
        at org.jetbrains.kotlin.serialization.DescriptorSerializer.propertyProto(DescriptorSerializer.kt:257)
        at org.jetbrains.kotlin.serialization.DescriptorSerializer.classProto(DescriptorSerializer.kt:116)
        at org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil.serializeDescriptors$serializeClasses(KotlinJavascriptSerializationUtil.kt:192)
        at org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil.serializeDescriptors(KotlinJavascriptSerializationUtil.kt:198)
        at org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtilKt.missingMetadata(KotlinJavascriptSerializationUtil.kt:319)
        at org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil.serializeMetadata(KotlinJavascriptSerializationUtil.kt:69)
        at org.jetbrains.dukat.descriptors.WriteDescriptorsToFileKt.convertToDescriptors(writeDescriptorsToFile.kt:59)
        at org.jetbrains.dukat.descriptors.WriteDescriptorsToFileKt.writeDescriptorsToFile(writeDescriptorsToFile.kt:114)
        at org.jetbrains.dukat.cli.CliKt.main(cli.kt:292)

Additional info:

$ java -version
openjdk version "1.8.0_342"
OpenJDK Runtime Environment (Zulu 8.64.0.15-CA-linux64) (build 1.8.0_342-b07)
OpenJDK 64-Bit Server VM (Zulu 8.64.0.15-CA-linux64) (build 25.342-b07, mixed mode)

$ node --version
v18.14.1

Related Issue

Maybe related to https://github.com/Kotlin/dukat/issues/477

hwvenancio commented 1 year ago

I forgot the --descriptors flag on the steps to reproduce. I edited/fixed the comment.