[IR] Add context receiver test on MFVC

Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
This commit is contained in:
Evgeniy.Zhelenskiy
2022-10-11 00:13:00 +02:00
committed by Space Team
parent fe1647096f
commit 0c70b60988
13 changed files with 56 additions and 44 deletions
@@ -11062,9 +11062,9 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
}
@Test
@TestMetadata("noContextReceiversOnInlineClasses.kt")
public void testNoContextReceiversOnInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
@TestMetadata("noContextReceiversOnValueClasses.kt")
public void testNoContextReceiversOnValueClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithUniversal());
}
@Test
@@ -11068,9 +11068,9 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
}
@Test
@TestMetadata("noContextReceiversOnInlineClasses.kt")
public void testNoContextReceiversOnInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
@TestMetadata("noContextReceiversOnValueClasses.kt")
public void testNoContextReceiversOnValueClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithUniversal());
}
@Test
@@ -11062,9 +11062,9 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
}
@Test
@TestMetadata("noContextReceiversOnInlineClasses.kt")
public void testNoContextReceiversOnInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
@TestMetadata("noContextReceiversOnValueClasses.kt")
public void testNoContextReceiversOnValueClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithUniversal());
}
@Test
@@ -52,6 +52,8 @@ object FirInlineClassDeclarationChecker : FirRegularClassChecker() {
reporter.reportOn(declaration.source, FirErrors.VALUE_CLASS_NOT_FINAL, context)
}
// TODO check absence of context receivers when FIR infrastructure is ready
for (supertypeEntry in declaration.superTypeRefs) {
if (supertypeEntry.toRegularClassSymbol(context.session)?.isInterface != true) {
reporter.reportOn(supertypeEntry.source, FirErrors.VALUE_CLASS_CANNOT_EXTEND_CLASSES, context)
@@ -425,8 +425,8 @@ public interface Errors {
DiagnosticFactory0<PsiElement> INNER_CLASS_INSIDE_VALUE_CLASS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> VALUE_CLASS_CANNOT_BE_CLONEABLE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INLINE_CLASS_DEPRECATED = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<KtContextReceiverList> INLINE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<KtNamedFunction, KotlinType> INEFFICIENT_EQUALS_OVERRIDING_IN_INLINE_CLASS =
DiagnosticFactory0<KtContextReceiverList> VALUE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<KtNamedFunction, KotlinType> INEFFICIENT_EQUALS_OVERRIDING_IN_VALUE_CLASS =
DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
// Result class
@@ -800,7 +800,7 @@ public class DefaultErrorMessages {
MAP.put(INNER_CLASS_INSIDE_VALUE_CLASS, "Value class cannot have inner classes");
MAP.put(VALUE_CLASS_CANNOT_BE_CLONEABLE, "Value class cannot be Cloneable");
MAP.put(INLINE_CLASS_DEPRECATED, "'inline' modifier is deprecated. Use 'value' instead");
MAP.put(INLINE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS, "Inline classes cannot have context receivers");
MAP.put(VALUE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS, "Value classes cannot have context receivers");
MAP.put(INEFFICIENT_EQUALS_OVERRIDING_IN_INLINE_CLASS,
"Overriding ''equals'' from ''Any'' in inline class without operator ''equals(other: {0}): Boolean'' leads to boxing on every equality comparison",
RENDER_TYPE);
@@ -62,7 +62,7 @@ object InlineClassDeclarationChecker : DeclarationChecker {
if (declaration.contextReceivers.isNotEmpty()) {
val contextReceiverList = declaration.getContextReceiverList()
requireNotNull(contextReceiverList) { "Declaration cannot have context receivers with no context receiver list" }
trace.report(Errors.INLINE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS.on(contextReceiverList))
trace.report(Errors.VALUE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS.on(contextReceiverList))
}
val modalityModifier = declaration.modalityModifier()
@@ -1,6 +0,0 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +ContextReceivers
class A
context(A)
inline class B(val x: Int)
@@ -1,6 +0,0 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +ContextReceivers
class A
<!INLINE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS!>context(A)<!>
inline class B(val x: Int)
@@ -1,16 +0,0 @@
package
public final class A {
public constructor A()
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
}
context(A) public final inline class B {
public constructor B(/*0*/ x: kotlin.Int)
public final val x: kotlin.Int
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
@@ -0,0 +1,19 @@
// !LANGUAGE: +ContextReceivers, +ValueClasses
// WITH_STDLIB
// SKIP_TXT
// WORKS_WHEN_VALUE_CLASS
@file:Suppress("INLINE_CLASS_DEPRECATED")
class A
context(A)
inline class B1(val x: Int)
context(A)
OPTIONAL_JVM_INLINE_ANNOTATION
value class B2(val x: Int)
context(A)
OPTIONAL_JVM_INLINE_ANNOTATION
value class C(val x: Int, val y: Int)
@@ -0,0 +1,19 @@
// !LANGUAGE: +ContextReceivers, +ValueClasses
// WITH_STDLIB
// SKIP_TXT
// WORKS_WHEN_VALUE_CLASS
@file:Suppress("INLINE_CLASS_DEPRECATED")
class A
<!VALUE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS!>context(A)<!>
inline class B1(val x: Int)
<!VALUE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS!>context(A)<!>
OPTIONAL_JVM_INLINE_ANNOTATION
value class B2(val x: Int)
<!VALUE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS!>context(A)<!>
OPTIONAL_JVM_INLINE_ANNOTATION
value class C(val x: Int, val y: Int)
@@ -11068,9 +11068,9 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
}
@Test
@TestMetadata("noContextReceiversOnInlineClasses.kt")
public void testNoContextReceiversOnInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
@TestMetadata("noContextReceiversOnValueClasses.kt")
public void testNoContextReceiversOnValueClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithUniversal());
}
@Test