diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt index d503f0b0a6a..f1f5c1c21a8 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.types.ConeClassErrorType +import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.load.java.JavaClassFinder import org.jetbrains.kotlin.load.java.JvmAnnotationNames @@ -163,17 +164,24 @@ class JavaSymbolProvider( for (javaConstructor in javaClass.constructors) { val constructorId = CallableId(classId.packageFqName, classId.relativeClassName, classId.shortClassName) val constructorSymbol = FirFunctionSymbol(constructorId) + val classTypeParameters = typeParameters.map { + createTypeParameterSymbol(this@JavaSymbolProvider.session, it.name).fir + } + val constructorTypeParameters = javaConstructor.typeParameters.map { + createTypeParameterSymbol(this@JavaSymbolProvider.session, it.name).fir + } + val typeParameters = classTypeParameters + constructorTypeParameters val firJavaConstructor = FirJavaConstructor( this@JavaSymbolProvider.session, constructorSymbol, javaConstructor.visibility, FirResolvedTypeRefImpl( this@JavaSymbolProvider.session, null, - firSymbol.constructType(emptyArray(), false), + firSymbol.constructType( + classTypeParameters.map { ConeTypeParameterTypeImpl(it.symbol, false) }.toTypedArray(), false + ), false, emptyList() ) ).apply { - for (typeParameter in javaConstructor.typeParameters) { - typeParameters += createTypeParameterSymbol(this@JavaSymbolProvider.session, typeParameter.name).fir - } + this.typeParameters += typeParameters addAnnotationsFrom(this@JavaSymbolProvider.session, javaConstructor) for (valueParameter in javaConstructor.valueParameters) { valueParameters += valueParameter.toFirValueParameters(this@JavaSymbolProvider.session) diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/ConstructorWithNewTypeParams.fir.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/ConstructorWithNewTypeParams.fir.txt index 195cdd0393e..17996df11bb 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/ConstructorWithNewTypeParams.fir.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/ConstructorWithNewTypeParams.fir.txt @@ -1,4 +1,4 @@ public open class ConstructorWithNewTypeParams : R|java/lang/Object| { - public constructor(first: R|ft|!): R|test/ConstructorWithNewTypeParams| + public constructor(first: R|ft|!): R|test/ConstructorWithNewTypeParams| } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/ConstructorWithParentTypeParams.fir.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/ConstructorWithParentTypeParams.fir.txt index 80045cfc712..936efdba8ff 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/ConstructorWithParentTypeParams.fir.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/ConstructorWithParentTypeParams.fir.txt @@ -1,4 +1,4 @@ public open class ConstructorWithParentTypeParams : R|java/lang/Object| { - public constructor(first: R|ft|!): R|test/ConstructorWithParentTypeParams| + public constructor(first: R|ft|!): R|test/ConstructorWithParentTypeParams| }