Files
kotlin-fork/compiler/testData/codegen/box/enum/manyDefaultParameters.kt
T
Nikolay Lunyak a9343aeb7d [FIR] KT-55840: Ensure everything actually works
This inconsistency is present due to not using the `// WITH_STDLIB`
in the above tests. When K1 creates the enum, it tries to generate
`entries()`, and for that it tries to load `kotlin.enums.EnumEntries`,
but this is actually an unresolved reference. K1 silently swallows it,
and proceeds.

The reason K2 doesn't fail is that in order to generate `entries()` it
simply creates the necessary `ConeClassLikeType` with the desired
`classId` instead of loading the whole `ClassDescriptor`.

The reason we can still observe `$ENTRIES` and `$entries` in K1
is because they are generated during the JVM codegen, and it
only checks if the `EnumEntries` language feature is supported. It
doesn't check if the `entries` property has really existed in IR
(by this time it's expected to have already been lowered to the
`get-entries` function - that's why "has ... existed").

The reason why the codegen doesn't fail when working with
`kotlin.enums.EnumEntries` is because it creates its
own `IrClassSymbol`.

^KT-55840 Fixed

Merge-request: KT-MR-8727
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-02-10 16:57:51 +00:00

57 lines
1.6 KiB
Kotlin
Vendored

// WITH_STDLIB
enum class ClassTemplate(
// var bug: Int = 1,
var code: Int,
var nameTemplate: Int = 1,
val parent: Int = 1,
val previous: Int = 1,
val progressionEquivalent: Int = 1,
var idDiscipline: Int = 1,
var strictRunningOrder: Int = 1,
var pointsMethod: Int = 1,
var noTimeFaults: Int = 1,
var combineHeights: Int = 1,
var column: Int = 1,
var runningOrderSort: Int = 1,
var programme: Int = 1,
var eliminationTime: Int = 1,
var courseTimeCode: Int = 1,
var teamSize: Int = 1,
var sponsor: Int = 1,
var lateEntryCredits: Int = 1,
var lateEntryFee: Int = 1,
var courseLengthNeeded: Int = 1,
var discretionaryCourseTime: Int = 1,
var isRelay: Int = 1,
var isQualifier: Int = 1,
var generateChildren: Int = 1,
var feedFromParent: Int = 1,
var isNfcAllowed: Int = 1,
var isAddOnAllowed: Int = 1,
var isSpecialEntry: Int = 1,
var isUkaProgression: Int = 1,
var canEnterDirectly: Int = 1,
var isPointRanked: Int = 1,
var isPointRankedDesc: Int = 1
) {
UNDEFINED(code = 56, nameTemplate = 3),
BLAH(code = 57, nameTemplate = 4)
}
fun box(): String {
val x = ClassTemplate.UNDEFINED
val y = ClassTemplate.BLAH
if (x.code != 56 || x.nameTemplate != 3 || x.isAddOnAllowed != 1) return "fail 1"
if (y.code != 57 || y.nameTemplate != 4 || y.isAddOnAllowed != 1) return "fail 2"
return "OK"
}