[FE 1.0] Use original receivers for NI while DSL scope violation checking

Original receivers are already use in the near place

^KT-46969 Fixed
This commit is contained in:
Victor Petukhov
2022-07-27 20:16:02 +02:00
committed by teamcity
parent eee35af7f9
commit a61648651b
7 changed files with 72 additions and 1 deletions
@@ -26061,6 +26061,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt31360.kt");
}
@Test
@TestMetadata("kt46969.kt")
public void testKt46969() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt46969.kt");
}
@Test
@TestMetadata("markedReceiverWithCapturedTypeArgument.kt")
public void testMarkedReceiverWithCapturedTypeArgument() throws Exception {
@@ -26061,6 +26061,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt31360.kt");
}
@Test
@TestMetadata("kt46969.kt")
public void testKt46969() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt46969.kt");
}
@Test
@TestMetadata("markedReceiverWithCapturedTypeArgument.kt")
public void testMarkedReceiverWithCapturedTypeArgument() throws Exception {
@@ -26061,6 +26061,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt31360.kt");
}
@Test
@TestMetadata("kt46969.kt")
public void testKt46969() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt46969.kt");
}
@Test
@TestMetadata("markedReceiverWithCapturedTypeArgument.kt")
public void testMarkedReceiverWithCapturedTypeArgument() throws Exception {
@@ -47,11 +47,12 @@ object DslScopeViolationCallChecker : CallChecker {
reportOn: PsiElement,
context: CallCheckerContext
) {
val isNewInferenceEnabled = context.languageVersionSettings.supportsFeature(LanguageFeature.NewInference)
val receiversUntilOneFromTheCall =
context.scope.parentsWithSelf
.filterIsInstance<LexicalScope>()
.flatMap { listOfNotNull(it.implicitReceiver) + it.contextReceiversGroup }
.map { it.value }
.map { if (isNewInferenceEnabled) it.value.original else it.value }
.takeWhile { it != callImplicitReceiver }.toList()
if (receiversUntilOneFromTheCall.isEmpty()) return
@@ -0,0 +1,26 @@
// FIR_IDENTICAL
@DslMarker
annotation class Foo
@Foo
interface Scope<T> {
fun value(value: T)
}
fun foo(block: Scope<Nothing>.() -> Unit) {}
inline fun <reified T> Scope<*>.nested(noinline block: Scope<T>.() -> Unit) {}
inline fun <reified K> Scope<*>.nested2(noinline block: Scope<K>.() -> Unit) {}
fun main() {
foo {
nested {
value(1)
nested2 {
value("foo")
}
}
}
}
@@ -0,0 +1,20 @@
package
public fun foo(/*0*/ block: Scope<kotlin.Nothing>.() -> kotlin.Unit): kotlin.Unit
public fun main(): kotlin.Unit
public inline fun </*0*/ reified T> Scope<*>.nested(/*0*/ noinline block: Scope<T>.() -> kotlin.Unit): kotlin.Unit
public inline fun </*0*/ reified K> Scope<*>.nested2(/*0*/ noinline block: Scope<K>.() -> kotlin.Unit): kotlin.Unit
@kotlin.DslMarker public final annotation class Foo : kotlin.Annotation {
public constructor Foo()
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
}
@Foo public interface Scope</*0*/ T> {
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
public abstract fun value(/*0*/ value: T): kotlin.Unit
}
@@ -26073,6 +26073,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt31360.kt");
}
@Test
@TestMetadata("kt46969.kt")
public void testKt46969() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt46969.kt");
}
@Test
@TestMetadata("markedReceiverWithCapturedTypeArgument.kt")
public void testMarkedReceiverWithCapturedTypeArgument() throws Exception {