[FE] Prohibit actual typealias to certain compiler annotations

^KT-58554
This commit is contained in:
Roman Efremov
2023-07-13 11:29:24 +02:00
committed by Space Team
parent f4a648aa3e
commit a79282cec1
21 changed files with 198 additions and 0 deletions
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.resolve.calls.mpp
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.name.ClassId
object ActualTypealiasToSpecialAnnotationUtils {
/**
* Type aliases may be useful to commonize some platform-specific annotations, e.g. [kotlin.jvm.Synchronized].
* We cannot universally determine at compile time whether annotation is accessible in common code.
* Instead, we prohibit certain package names because we are sure that annotations from them
* are visible in common and there is no point to typealias them.
*/
private val FORBIDDEN_PACKAGES = setOf(
StandardNames.ANNOTATION_PACKAGE_FQ_NAME,
StandardNames.BUILT_INS_PACKAGE_FQ_NAME,
StandardNames.KOTLIN_INTERNAL_FQ_NAME,
)
fun isAnnotationProhibitedInActualTypeAlias(classId: ClassId): Boolean {
return classId.packageFqName in FORBIDDEN_PACKAGES
}
}