diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ClassLiteralChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ClassLiteralChecker.kt new file mode 100644 index 00000000000..3ec7a84bbaf --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ClassLiteralChecker.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.types.expressions + +import org.jetbrains.kotlin.psi.KtClassLiteralExpression +import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext +import org.jetbrains.kotlin.types.KotlinType + +interface ClassLiteralChecker { + fun check(expression: KtClassLiteralExpression, type: KotlinType, context: ResolutionContext<*>) +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt index c502de18686..03e664bd722 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt @@ -76,7 +76,8 @@ class DoubleColonExpressionResolver( val dataFlowAnalyzer: DataFlowAnalyzer, val reflectionTypes: ReflectionTypes, val typeResolver: TypeResolver, - val languageVersionSettings: LanguageVersionSettings + val languageVersionSettings: LanguageVersionSettings, + val additionalCheckers: Iterable ) { private lateinit var expressionTypingServices: ExpressionTypingServices @@ -137,6 +138,9 @@ class DoubleColonExpressionResolver( else if (!result.possiblyBareType.isBare && !isAllowedInClassLiteral(type)) { c.trace.report(CLASS_LITERAL_LHS_NOT_A_CLASS.on(expression)) } + for (additionalChecker in additionalCheckers) { + additionalChecker.check(expression, type, c) + } } // Returns true if the expression is not a call expression without value arguments (such as "A") or a qualified expression