[IR] Add context receiver test on MFVC
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com> #KT-1179
This commit is contained in:
committed by
Space Team
parent
fe1647096f
commit
0c70b60988
+3
-3
@@ -11062,9 +11062,9 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noContextReceiversOnInlineClasses.kt")
|
@TestMetadata("noContextReceiversOnValueClasses.kt")
|
||||||
public void testNoContextReceiversOnInlineClasses() throws Exception {
|
public void testNoContextReceiversOnValueClasses() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
|
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithUniversal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+3
-3
@@ -11068,9 +11068,9 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noContextReceiversOnInlineClasses.kt")
|
@TestMetadata("noContextReceiversOnValueClasses.kt")
|
||||||
public void testNoContextReceiversOnInlineClasses() throws Exception {
|
public void testNoContextReceiversOnValueClasses() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
|
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithUniversal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+3
-3
@@ -11062,9 +11062,9 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noContextReceiversOnInlineClasses.kt")
|
@TestMetadata("noContextReceiversOnValueClasses.kt")
|
||||||
public void testNoContextReceiversOnInlineClasses() throws Exception {
|
public void testNoContextReceiversOnValueClasses() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
|
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithUniversal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+2
@@ -52,6 +52,8 @@ object FirInlineClassDeclarationChecker : FirRegularClassChecker() {
|
|||||||
reporter.reportOn(declaration.source, FirErrors.VALUE_CLASS_NOT_FINAL, context)
|
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) {
|
for (supertypeEntry in declaration.superTypeRefs) {
|
||||||
if (supertypeEntry.toRegularClassSymbol(context.session)?.isInterface != true) {
|
if (supertypeEntry.toRegularClassSymbol(context.session)?.isInterface != true) {
|
||||||
reporter.reportOn(supertypeEntry.source, FirErrors.VALUE_CLASS_CANNOT_EXTEND_CLASSES, context)
|
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> INNER_CLASS_INSIDE_VALUE_CLASS = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> VALUE_CLASS_CANNOT_BE_CLONEABLE = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> VALUE_CLASS_CANNOT_BE_CLONEABLE = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> INLINE_CLASS_DEPRECATED = DiagnosticFactory0.create(WARNING);
|
DiagnosticFactory0<PsiElement> INLINE_CLASS_DEPRECATED = DiagnosticFactory0.create(WARNING);
|
||||||
DiagnosticFactory0<KtContextReceiverList> INLINE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<KtContextReceiverList> VALUE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory1<KtNamedFunction, KotlinType> INEFFICIENT_EQUALS_OVERRIDING_IN_INLINE_CLASS =
|
DiagnosticFactory1<KtNamedFunction, KotlinType> INEFFICIENT_EQUALS_OVERRIDING_IN_VALUE_CLASS =
|
||||||
DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||||
|
|
||||||
// Result class
|
// Result class
|
||||||
|
|||||||
+1
-1
@@ -800,7 +800,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(INNER_CLASS_INSIDE_VALUE_CLASS, "Value class cannot have inner classes");
|
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(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_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,
|
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",
|
"Overriding ''equals'' from ''Any'' in inline class without operator ''equals(other: {0}): Boolean'' leads to boxing on every equality comparison",
|
||||||
RENDER_TYPE);
|
RENDER_TYPE);
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ object InlineClassDeclarationChecker : DeclarationChecker {
|
|||||||
if (declaration.contextReceivers.isNotEmpty()) {
|
if (declaration.contextReceivers.isNotEmpty()) {
|
||||||
val contextReceiverList = declaration.getContextReceiverList()
|
val contextReceiverList = declaration.getContextReceiverList()
|
||||||
requireNotNull(contextReceiverList) { "Declaration cannot have context receivers with no context receiver list" }
|
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()
|
val modalityModifier = declaration.modalityModifier()
|
||||||
|
|||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +ContextReceivers
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
context(A)
|
|
||||||
inline class B(val x: Int)
|
|
||||||
compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt
Vendored
-6
@@ -1,6 +0,0 @@
|
|||||||
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +ContextReceivers
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
<!INLINE_CLASS_CANNOT_HAVE_CONTEXT_RECEIVERS!>context(A)<!>
|
|
||||||
inline class B(val x: Int)
|
|
||||||
-16
@@ -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
|
|
||||||
}
|
|
||||||
+19
@@ -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)
|
||||||
Vendored
+19
@@ -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)
|
||||||
Generated
+3
-3
@@ -11068,9 +11068,9 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noContextReceiversOnInlineClasses.kt")
|
@TestMetadata("noContextReceiversOnValueClasses.kt")
|
||||||
public void testNoContextReceiversOnInlineClasses() throws Exception {
|
public void testNoContextReceiversOnValueClasses() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
|
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithUniversal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user