[Wasm] Add K2 checkers.wasm module (KT-56849)

Add first K2 checker ExternalInheritanceChecker to test the infra
This commit is contained in:
Svyatoslav Kuzmich
2023-08-30 16:10:29 +02:00
committed by Space Team
parent 0da9cf8159
commit a10042f909
20 changed files with 218 additions and 7 deletions
@@ -16,6 +16,7 @@ dependencies {
api(project(":compiler:fir:checkers:checkers.jvm"))
api(project(":compiler:fir:checkers:checkers.js"))
api(project(":compiler:fir:checkers:checkers.native"))
api(project(":compiler:fir:checkers:checkers.wasm"))
api(project(":compiler:fir:java"))
api(project(":compiler:backend.common.jvm"))
api(project(":analysis:analysis-api-impl-barebone"))
+1
View File
@@ -167,6 +167,7 @@ val firCompilerCoreModules = arrayOf(
":compiler:fir:checkers:checkers.jvm",
":compiler:fir:checkers:checkers.js",
":compiler:fir:checkers:checkers.native",
":compiler:fir:checkers:checkers.wasm",
":compiler:fir:entrypoint", // TODO should not be in core modules but FIR IDE uses DependencyListForCliModule from this module
":compiler:fir:fir2ir:jvm-backend", // TODO should not be in core modules but FIR IDE uses Fir2IrSignatureComposer from this module
":compiler:fir:fir2ir" // TODO should not be in core modules but FIR IDE uses Fir2IrSignatureComposer from this module
+1
View File
@@ -26,6 +26,7 @@ dependencies {
api(project(":compiler:fir:checkers:checkers.jvm"))
api(project(":compiler:fir:checkers:checkers.js"))
api(project(":compiler:fir:checkers:checkers.native"))
api(project(":compiler:fir:checkers:checkers.wasm"))
api(project(":compiler:fir:fir-serialization"))
api(project(":kotlin-util-io"))
@@ -22,6 +22,7 @@ dependencies {
testApi(project(":compiler:fir:checkers:checkers.jvm"))
testApi(project(":compiler:fir:checkers:checkers.js"))
testApi(project(":compiler:fir:checkers:checkers.native"))
testApi(project(":compiler:fir:checkers:checkers.wasm"))
testApi(project(":compiler:fir:fir-serialization"))
testApi(project(":compiler:fir:entrypoint"))
testApi(project(":compiler:frontend"))
@@ -21,6 +21,7 @@ dependencies {
testApi(project(":compiler:fir:checkers:checkers.jvm"))
testApi(project(":compiler:fir:checkers:checkers.js"))
testApi(project(":compiler:fir:checkers:checkers.native"))
testApi(project(":compiler:fir:checkers:checkers.wasm"))
testApi(project(":compiler:fir:entrypoint"))
testApi(project(":compiler:frontend"))
+1
View File
@@ -38,6 +38,7 @@ val platformGenerationRoots = listOf(
"checkers.jvm",
"checkers.js",
"checkers.native",
"checkers.wasm",
).map { projectDir.resolve(it).resolve("gen") }
val generateCheckersComponents by tasks.registering(NoDebugJavaExec::class) {
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DIAGNOSTICS_LIST
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.JS_DIAGNOSTICS_LIST
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.JVM_DIAGNOSTICS_LIST
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.NATIVE_DIAGNOSTICS_LIST
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.WASM_DIAGNOSTICS_LIST
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.ErrorListDiagnosticListRenderer
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.generateDiagnostics
import org.jetbrains.kotlin.fir.declarations.*
@@ -101,6 +102,7 @@ fun main(args: Array<String>) {
val jvmGenerationPath = File(arguments.getOrElse(1) { "compiler/fir/checkers/checkers.jvm/gen" })
val jsGenerationPath = File(arguments.getOrElse(2) { "compiler/fir/checkers/checkers.js/gen" })
val nativeGenerationPath = File(arguments.getOrElse(3) { "compiler/fir/checkers/checkers.native/gen" })
val wasmGenerationPath = File(arguments.getOrElse(4) { "compiler/fir/checkers/checkers.wasm/gen" })
val rawFirGenerationPath = File("compiler/fir/raw-fir/raw-fir.common/gen")
val packageName = "$basePackage.diagnostics"
@@ -109,6 +111,7 @@ fun main(args: Array<String>) {
generateDiagnostics(jvmGenerationPath, "$packageName.jvm", JVM_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
generateDiagnostics(jsGenerationPath, "$packageName.js", JS_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
generateDiagnostics(nativeGenerationPath, "$packageName.native", NATIVE_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
generateDiagnostics(wasmGenerationPath, "$packageName.wasm", WASM_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
generateDiagnostics(rawFirGenerationPath, "org.jetbrains.kotlin.fir.builder", SYNTAX_DIAGNOSTIC_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
generateNonSuppressibleErrorNamesFile(generationPath, packageName)
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2021 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.fir.checkers.generator.diagnostics
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.diagnostics.error1
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.DiagnosticList
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.PositioningStrategy
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.util.PrivateForInline
@Suppress("ClassName", "unused")
@OptIn(PrivateForInline::class)
object WASM_DIAGNOSTICS_LIST : DiagnosticList("FirWasmErrors") {
val EXTERNALS by object : DiagnosticGroup("Externals") {
val NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE by error<KtElement>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) {
parameter<ConeKotlinType>("superType")
}
}
}
@@ -0,0 +1,38 @@
import org.jetbrains.kotlin.ideaExt.idea
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
api(project(":compiler:fir:checkers"))
api(project(":core:compiler.common.wasm"))
/*
* We can't remove this dependency until we use
* diagnostics framework from FE 1.0
*/
implementation(project(":compiler:frontend"))
implementation(project(":compiler:psi"))
compileOnly(intellijCore())
}
sourceSets {
"main" {
projectDefault()
generatedDir()
}
"test" { none() }
}
val compileKotlin by tasks
compileKotlin.dependsOn(":compiler:fir:checkers:generateCheckersComponents")
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
apply(plugin = "idea")
idea {
this.module.generatedSourceDirs.add(projectDir.resolve("gen"))
}
}
@@ -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.fir.analysis.diagnostics.wasm
import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.diagnostics.SourceElementPositioningStrategies
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.psi.KtElement
/*
* This file was generated automatically
* DO NOT MODIFY IT MANUALLY
*/
object FirWasmErrors {
// Externals
val NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE by error1<KtElement, ConeKotlinType>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
init {
RootDiagnosticRendererFactory.registerFactory(FirWasmErrorsDefaultMessages)
}
}
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2021 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.fir.analysis.diagnostics.wasm
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers
import org.jetbrains.kotlin.fir.analysis.diagnostics.wasm.FirWasmErrors.NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE
@Suppress("unused")
object FirWasmErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
override val MAP = KtDiagnosticFactoryToRendererMap("FIR").also { map ->
map.put(NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE, "Non-external type extends external type {0}", FirDiagnosticRenderers.RENDER_TYPE)
}
}
@@ -0,0 +1,28 @@
/*
* Copyright 2010-2021 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.fir.analysis.wasm.checkers
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.*
import org.jetbrains.kotlin.fir.analysis.wasm.checkers.declaration.*
object WasmDeclarationCheckers : DeclarationCheckers() {
override val functionCheckers: Set<FirFunctionChecker>
get() = setOf(
)
override val basicDeclarationCheckers: Set<FirBasicDeclarationChecker>
get() = setOf(
)
override val classCheckers: Set<FirClassChecker>
get() = setOf(
FirWasmExternalInheritanceChecker
)
override val simpleFunctionCheckers: Set<FirSimpleFunctionChecker>
get() = setOf(
)
}
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2021 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.fir.analysis.wasm.checkers
import org.jetbrains.kotlin.fir.analysis.checkers.expression.*
object WasmExpressionCheckers : ExpressionCheckers() {
override val annotationCallCheckers: Set<FirAnnotationCallChecker>
get() = setOf(
)
override val basicExpressionCheckers: Set<FirBasicExpressionChecker>
get() = setOf(
)
override val functionCallCheckers: Set<FirFunctionCallChecker>
get() = setOf(
)
override val callCheckers: Set<FirCallChecker>
get() = setOf(
)
}
@@ -0,0 +1,34 @@
/*
* 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.fir.analysis.wasm.checkers.declaration
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirClassChecker
import org.jetbrains.kotlin.fir.analysis.checkers.toClassLikeSymbol
import org.jetbrains.kotlin.fir.analysis.diagnostics.wasm.FirWasmErrors
import org.jetbrains.kotlin.fir.declarations.utils.isEffectivelyExternal
import org.jetbrains.kotlin.fir.declarations.FirClass
import org.jetbrains.kotlin.fir.types.coneType
object FirWasmExternalInheritanceChecker : FirClassChecker() {
override fun check(declaration: FirClass, context: CheckerContext, reporter: DiagnosticReporter) {
val session = context.session
if (!declaration.symbol.isEffectivelyExternal(session)) {
for (superTypeRef in declaration.superTypeRefs) {
if (superTypeRef.toClassLikeSymbol(session)?.isEffectivelyExternal(session) == true) {
reporter.reportOn(
declaration.source,
FirWasmErrors.NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE,
superTypeRef.coneType,
context
)
}
}
}
}
}
+1
View File
@@ -14,6 +14,7 @@ dependencies {
api(project(":compiler:fir:checkers:checkers.jvm"))
api(project(":compiler:fir:checkers:checkers.js"))
api(project(":compiler:fir:checkers:checkers.native"))
api(project(":compiler:fir:checkers:checkers.wasm"))
api(project(":js:js.frontend"))
implementation(project(":core:compiler.common.native"))
@@ -13,6 +13,8 @@ import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmExpressionCheckers
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmTypeCheckers
import org.jetbrains.kotlin.fir.analysis.native.checkers.NativeDeclarationCheckers
import org.jetbrains.kotlin.fir.analysis.native.checkers.NativeExpressionCheckers
import org.jetbrains.kotlin.fir.analysis.wasm.checkers.WasmDeclarationCheckers
import org.jetbrains.kotlin.fir.analysis.wasm.checkers.WasmExpressionCheckers
import org.jetbrains.kotlin.fir.session.FirSessionConfigurator
fun FirSessionConfigurator.registerCommonCheckers() {
@@ -46,5 +48,6 @@ fun FirSessionConfigurator.registerNativeCheckers() {
}
fun FirSessionConfigurator.registerWasmCheckers() {
// TODO: Implement Wasm checkers (KT-56849)
useCheckers(WasmDeclarationCheckers)
useCheckers(WasmExpressionCheckers)
}
@@ -10,13 +10,13 @@ external class EC3 : I1, C1
external interface EI1 : I1
interface I2 : EI1
interface <!NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE!>I2<!> : EI1
class C3 : EI1
class <!NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE!>C3<!> : EI1
class C4 : EI1, EC1()
class <!NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE, NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE!>C4<!> : EI1, EC1()
object O1 : EC1()
<!NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE!>object O1<!> : EC1()
val x1: Any = object : EI1 {}
val x2: Any = object : EC1() {}
val x1: Any = <!NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE!>object<!> : EI1 {}
val x2: Any = <!NON_EXTERNAL_TYPE_EXTENDS_EXTERNAL_TYPE!>object<!> : EC1() {}
+1
View File
@@ -29,6 +29,7 @@ dependencies {
testApi(project(":compiler:fir:checkers:checkers.jvm"))
testApi(project(":compiler:fir:checkers:checkers.js"))
testApi(project(":compiler:fir:checkers:checkers.native"))
testApi(project(":compiler:fir:checkers:checkers.wasm"))
testApi(project(":compiler:fir:java"))
testApi(project(":compiler:fir:entrypoint"))
testApi(project(":compiler:ir.ir2cfg"))
@@ -31,6 +31,7 @@ dependencies {
testApi(project(":compiler:fir:checkers:checkers.jvm"))
testApi(project(":compiler:fir:checkers:checkers.js"))
testApi(project(":compiler:fir:checkers:checkers.native"))
testApi(project(":compiler:fir:checkers:checkers.wasm"))
testApi(project(":compiler:fir:plugin-utils"))
testRuntimeOnly(project(":core:descriptors.runtime"))
+1
View File
@@ -300,6 +300,7 @@ include ":compiler:fir",
":compiler:fir:checkers:checkers.jvm",
":compiler:fir:checkers:checkers.js",
":compiler:fir:checkers:checkers.native",
":compiler:fir:checkers:checkers.wasm",
":compiler:fir:checkers:checkers-component-generator",
":compiler:fir:entrypoint",
":compiler:fir:analysis-tests",