[FIR JS] Add the dynamic type unsupported checker
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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.jvm.checkers
|
||||
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirDynamicUnsupportedChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.type.*
|
||||
|
||||
object JvmTypeCheckers : TypeCheckers() {
|
||||
override val typeRefCheckers: Set<FirTypeRefChecker> = setOf(
|
||||
FirDynamicUnsupportedChecker,
|
||||
)
|
||||
}
|
||||
+26
@@ -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.checkers.declaration
|
||||
|
||||
import org.jetbrains.kotlin.KtRealSourceElementKind
|
||||
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.type.FirTypeRefChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.types.ConeDynamicType
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||
|
||||
object FirDynamicUnsupportedChecker : FirTypeRefChecker() {
|
||||
override fun check(typeRef: FirTypeRef, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
// It's assumed this checker is only called
|
||||
// by within the platform that disallows dynamics
|
||||
if (typeRef.coneTypeSafe<ConeDynamicType>() != null) {
|
||||
reporter.reportOn(typeRef.source, FirErrors.UNSUPPORTED, "dynamic type", context)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.analysis.js.checkers.JsDeclarationCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.js.checkers.JsExpressionCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmDeclarationCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmExpressionCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmTypeCheckers
|
||||
import org.jetbrains.kotlin.fir.session.FirSessionFactory
|
||||
|
||||
fun FirSessionFactory.FirSessionConfigurator.registerCommonCheckers() {
|
||||
@@ -27,6 +28,7 @@ fun FirSessionFactory.FirSessionConfigurator.registerExtendedCommonCheckers() {
|
||||
fun FirSessionFactory.FirSessionConfigurator.registerJvmCheckers() {
|
||||
useCheckers(JvmDeclarationCheckers)
|
||||
useCheckers(JvmExpressionCheckers)
|
||||
useCheckers(JvmTypeCheckers)
|
||||
}
|
||||
|
||||
fun FirSessionFactory.FirSessionConfigurator.registerJsCheckers() {
|
||||
|
||||
Reference in New Issue
Block a user