Do not report DSL scope violation error when language-version is 1.0
#KT-11551 Fixed
This commit is contained in:
+2
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
@@ -32,6 +33,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.parentsWithSelf
|
|||||||
|
|
||||||
object DslScopeViolationCallChecker : CallChecker {
|
object DslScopeViolationCallChecker : CallChecker {
|
||||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||||
|
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.DslMarkersSupport)) return
|
||||||
val callImplicitReceivers = resolvedCall.getImplicitReceivers()
|
val callImplicitReceivers = resolvedCall.getImplicitReceivers()
|
||||||
|
|
||||||
for (callImplicitReceiver in callImplicitReceivers) {
|
for (callImplicitReceiver in callImplicitReceivers) {
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// !LANGUAGE: -DslMarkersSupport
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
@DslMarker
|
||||||
|
annotation class Ann
|
||||||
|
|
||||||
|
@Ann
|
||||||
|
class A {
|
||||||
|
fun a() = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ann
|
||||||
|
class B {
|
||||||
|
fun b() = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(x: A.() -> Unit) {}
|
||||||
|
fun bar(x: B.() -> Unit) {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
foo {
|
||||||
|
a()
|
||||||
|
bar {
|
||||||
|
a()
|
||||||
|
this@foo.a()
|
||||||
|
b()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun bar(/*0*/ x: B.() -> kotlin.Unit): kotlin.Unit
|
||||||
|
public fun foo(/*0*/ x: A.() -> kotlin.Unit): kotlin.Unit
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
@Ann public final class A {
|
||||||
|
public constructor A()
|
||||||
|
public final fun a(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.DslMarker public final annotation class Ann : kotlin.Annotation {
|
||||||
|
public constructor Ann()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ann public final class B {
|
||||||
|
public constructor B()
|
||||||
|
public final fun b(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -15941,6 +15941,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unsupportedFeature.kt")
|
||||||
|
public void testUnsupportedFeature() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/unsupportedFeature.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("useOfExtensions.kt")
|
@TestMetadata("useOfExtensions.kt")
|
||||||
public void testUseOfExtensions() throws Exception {
|
public void testUseOfExtensions() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/useOfExtensions.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/useOfExtensions.kt");
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ enum class LanguageFeature(val sinceVersion: LanguageVersion) {
|
|||||||
DataClassInheritance(KOTLIN_1_1),
|
DataClassInheritance(KOTLIN_1_1),
|
||||||
InlineProperties(KOTLIN_1_1),
|
InlineProperties(KOTLIN_1_1),
|
||||||
DestructuringLambdaParameters(KOTLIN_1_1),
|
DestructuringLambdaParameters(KOTLIN_1_1),
|
||||||
SingleUnderscoreForParameterName(KOTLIN_1_1)
|
SingleUnderscoreForParameterName(KOTLIN_1_1),
|
||||||
|
DslMarkersSupport(KOTLIN_1_1)
|
||||||
;
|
;
|
||||||
|
|
||||||
val presentableText: String
|
val presentableText: String
|
||||||
|
|||||||
Reference in New Issue
Block a user