From 5c807266f657cb3f7c7dbbafba7fb95171f0ec55 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 30 Jan 2019 18:47:01 +0100 Subject: [PATCH] JVM IR: fix origin of file class in FileClassLowering IrDeclarationOrigin.FILE_CLASS is used in CallableReferenceLowering to generate correct declaration owner. Many reflection tests start to fail with this commit because they are now treating callable references to top level declarations as Kotlin symbols and fail because there's no JVM signature for them; this is fixed in subsequent commits (previously, they worked because without Kotlin metadata, these files were treated as Java classes) --- .../org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt | 2 +- .../box/collectionLiterals/collectionLiteralsWithConstants.kt | 1 + compiler/testData/codegen/box/jvmName/annotationProperties.kt | 1 + .../testData/codegen/box/reflection/annotations/retentions.kt | 1 + .../codegen/box/reflection/annotations/simpleFunAnnotation.kt | 1 + .../codegen/box/reflection/annotations/simpleParamAnnotation.kt | 1 + .../codegen/box/reflection/call/bound/extensionFunction.kt | 1 + .../codegen/box/reflection/callBy/nonDefaultParameterOmitted.kt | 1 + .../box/reflection/mapping/types/genericArrayElementType.kt | 1 + .../box/reflection/mapping/types/innerGenericTypeArgument.kt | 1 + .../box/reflection/mapping/types/parameterizedTypeArgument.kt | 1 + .../codegen/box/reflection/mapping/types/withNullability.kt | 1 + .../properties/privatePropertyCallIsAccessibleOnAccessors.kt | 1 - .../codegen/box/reflection/typeParameters/upperBounds.kt | 1 + .../testData/codegen/box/reflection/types/classifierIsClass.kt | 1 + .../codegen/box/reflection/types/classifiersOfBuiltInTypes.kt | 1 + .../testData/codegen/box/reflection/types/jvmErasureOfClass.kt | 1 + .../codegen/box/reflection/types/subtyping/platformType.kt | 1 + .../box/reflection/types/subtyping/simpleGenericTypes.kt | 1 + .../codegen/box/reflection/types/subtyping/typeProjection.kt | 1 + .../testData/codegen/box/reflection/types/useSiteVariance.kt | 1 + .../codegen/box/vararg/assigningArrayToVarargInAnnotation.kt | 1 + .../multiplatform/annotationsViaActualTypeAliasFromBinary.kt | 1 + 23 files changed, 22 insertions(+), 2 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt index 4054a69264f..d9096d8e379 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt @@ -71,7 +71,7 @@ private class FileClassLowering(val context: JvmBackendContext) : FileLoweringPa val descriptor = WrappedClassDescriptor(sourceElement = KotlinSourceElement(ktFile)) return IrClassImpl( 0, fileEntry.maxOffset, - IrDeclarationOrigin.DEFINED, + IrDeclarationOrigin.FILE_CLASS, symbol = IrClassSymbolImpl(descriptor), name = fileClassInfo.fileClassFqName.shortName(), kind = ClassKind.CLASS, diff --git a/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt b/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt index c565aab7244..1bf06b73d14 100644 --- a/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt +++ b/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // WITH_REFLECT // TARGET_BACKEND: JVM diff --git a/compiler/testData/codegen/box/jvmName/annotationProperties.kt b/compiler/testData/codegen/box/jvmName/annotationProperties.kt index 8d6f4876b18..fce25a4d2da 100644 --- a/compiler/testData/codegen/box/jvmName/annotationProperties.kt +++ b/compiler/testData/codegen/box/jvmName/annotationProperties.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT package test diff --git a/compiler/testData/codegen/box/reflection/annotations/retentions.kt b/compiler/testData/codegen/box/reflection/annotations/retentions.kt index 3d9597bd113..b3c2f35445c 100644 --- a/compiler/testData/codegen/box/reflection/annotations/retentions.kt +++ b/compiler/testData/codegen/box/reflection/annotations/retentions.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/annotations/simpleFunAnnotation.kt b/compiler/testData/codegen/box/reflection/annotations/simpleFunAnnotation.kt index 9bf7297f9b3..7d9e0893927 100644 --- a/compiler/testData/codegen/box/reflection/annotations/simpleFunAnnotation.kt +++ b/compiler/testData/codegen/box/reflection/annotations/simpleFunAnnotation.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/reflection/annotations/simpleParamAnnotation.kt b/compiler/testData/codegen/box/reflection/annotations/simpleParamAnnotation.kt index 6e642f79c54..49af2f9360e 100644 --- a/compiler/testData/codegen/box/reflection/annotations/simpleParamAnnotation.kt +++ b/compiler/testData/codegen/box/reflection/annotations/simpleParamAnnotation.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/reflection/call/bound/extensionFunction.kt b/compiler/testData/codegen/box/reflection/call/bound/extensionFunction.kt index 993e4820d8d..b18ee72af00 100644 --- a/compiler/testData/codegen/box/reflection/call/bound/extensionFunction.kt +++ b/compiler/testData/codegen/box/reflection/call/bound/extensionFunction.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/reflection/callBy/nonDefaultParameterOmitted.kt b/compiler/testData/codegen/box/reflection/callBy/nonDefaultParameterOmitted.kt index 51a03692991..9f036301883 100644 --- a/compiler/testData/codegen/box/reflection/callBy/nonDefaultParameterOmitted.kt +++ b/compiler/testData/codegen/box/reflection/callBy/nonDefaultParameterOmitted.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/reflection/mapping/types/genericArrayElementType.kt b/compiler/testData/codegen/box/reflection/mapping/types/genericArrayElementType.kt index d8c06d8cfcd..dc5789e8dbb 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/genericArrayElementType.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/genericArrayElementType.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/mapping/types/innerGenericTypeArgument.kt b/compiler/testData/codegen/box/reflection/mapping/types/innerGenericTypeArgument.kt index 6277c1abcfe..455461c89dd 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/innerGenericTypeArgument.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/innerGenericTypeArgument.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/mapping/types/parameterizedTypeArgument.kt b/compiler/testData/codegen/box/reflection/mapping/types/parameterizedTypeArgument.kt index e4d47a93bbf..d086bef8284 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/parameterizedTypeArgument.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/parameterizedTypeArgument.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/mapping/types/withNullability.kt b/compiler/testData/codegen/box/reflection/mapping/types/withNullability.kt index f55c3bf041b..034dca0e73b 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/withNullability.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/withNullability.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/properties/privatePropertyCallIsAccessibleOnAccessors.kt b/compiler/testData/codegen/box/reflection/properties/privatePropertyCallIsAccessibleOnAccessors.kt index 060de1620e1..7536cc3e2c0 100644 --- a/compiler/testData/codegen/box/reflection/properties/privatePropertyCallIsAccessibleOnAccessors.kt +++ b/compiler/testData/codegen/box/reflection/properties/privatePropertyCallIsAccessibleOnAccessors.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM - // WITH_REFLECT import kotlin.reflect.* diff --git a/compiler/testData/codegen/box/reflection/typeParameters/upperBounds.kt b/compiler/testData/codegen/box/reflection/typeParameters/upperBounds.kt index 2fdc4cea305..68413d3a6b2 100644 --- a/compiler/testData/codegen/box/reflection/typeParameters/upperBounds.kt +++ b/compiler/testData/codegen/box/reflection/typeParameters/upperBounds.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/reflection/types/classifierIsClass.kt b/compiler/testData/codegen/box/reflection/types/classifierIsClass.kt index d7e5396cbd9..1d0b234c434 100644 --- a/compiler/testData/codegen/box/reflection/types/classifierIsClass.kt +++ b/compiler/testData/codegen/box/reflection/types/classifierIsClass.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/reflection/types/classifiersOfBuiltInTypes.kt b/compiler/testData/codegen/box/reflection/types/classifiersOfBuiltInTypes.kt index cb7a4b70b99..e899f3526ce 100644 --- a/compiler/testData/codegen/box/reflection/types/classifiersOfBuiltInTypes.kt +++ b/compiler/testData/codegen/box/reflection/types/classifiersOfBuiltInTypes.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/types/jvmErasureOfClass.kt b/compiler/testData/codegen/box/reflection/types/jvmErasureOfClass.kt index bea77ac9c0f..01c927eabbc 100644 --- a/compiler/testData/codegen/box/reflection/types/jvmErasureOfClass.kt +++ b/compiler/testData/codegen/box/reflection/types/jvmErasureOfClass.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/types/subtyping/platformType.kt b/compiler/testData/codegen/box/reflection/types/subtyping/platformType.kt index f9932a50a7d..e14f13a955e 100644 --- a/compiler/testData/codegen/box/reflection/types/subtyping/platformType.kt +++ b/compiler/testData/codegen/box/reflection/types/subtyping/platformType.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/types/subtyping/simpleGenericTypes.kt b/compiler/testData/codegen/box/reflection/types/subtyping/simpleGenericTypes.kt index 56898204b25..019e398f7b7 100644 --- a/compiler/testData/codegen/box/reflection/types/subtyping/simpleGenericTypes.kt +++ b/compiler/testData/codegen/box/reflection/types/subtyping/simpleGenericTypes.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/reflection/types/subtyping/typeProjection.kt b/compiler/testData/codegen/box/reflection/types/subtyping/typeProjection.kt index 29863590942..f31f9bd4cdf 100644 --- a/compiler/testData/codegen/box/reflection/types/subtyping/typeProjection.kt +++ b/compiler/testData/codegen/box/reflection/types/subtyping/typeProjection.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/reflection/types/useSiteVariance.kt b/compiler/testData/codegen/box/reflection/types/useSiteVariance.kt index d6b0fc3fc1f..b4364479cd7 100644 --- a/compiler/testData/codegen/box/reflection/types/useSiteVariance.kt +++ b/compiler/testData/codegen/box/reflection/types/useSiteVariance.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/vararg/assigningArrayToVarargInAnnotation.kt b/compiler/testData/codegen/box/vararg/assigningArrayToVarargInAnnotation.kt index d8519bbb06a..03f3fd345f9 100644 --- a/compiler/testData/codegen/box/vararg/assigningArrayToVarargInAnnotation.kt +++ b/compiler/testData/codegen/box/vararg/assigningArrayToVarargInAnnotation.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // WITH_REFLECT // TARGET_BACKEND: JVM diff --git a/compiler/testData/codegen/boxAgainstJava/multiplatform/annotationsViaActualTypeAliasFromBinary.kt b/compiler/testData/codegen/boxAgainstJava/multiplatform/annotationsViaActualTypeAliasFromBinary.kt index 635fb7d069a..2be68b72930 100644 --- a/compiler/testData/codegen/boxAgainstJava/multiplatform/annotationsViaActualTypeAliasFromBinary.kt +++ b/compiler/testData/codegen/boxAgainstJava/multiplatform/annotationsViaActualTypeAliasFromBinary.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // !LANGUAGE: +MultiPlatformProjects // WITH_REFLECT // FILE: main.kt