FIR: add test for erroneous type inference in UAST (KT-48159)
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
FILE: UastPatterns.kt
|
||||
public abstract interface UElement : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface UExpression : R|UElement| {
|
||||
}
|
||||
public abstract interface UReferenceExpression : R|UExpression| {
|
||||
}
|
||||
public final fun injectionHostOrReferenceExpression(): R|UExpressionPattern.Capture<UExpression>| {
|
||||
^injectionHostOrReferenceExpression R|/uExpression|().<CS errors: /UExpressionPattern.Capture.filter>#(<L> = filter@fun <anonymous>(it: R|UExpression|): R|kotlin/Boolean| <inline=NoInline> {
|
||||
^ (R|<local>/it| is R|UReferenceExpression|)
|
||||
}
|
||||
)
|
||||
}
|
||||
public final fun uExpression(): R|UExpressionPattern.Capture<UExpression>| {
|
||||
^uExpression R|/expressionCapture|<R|UExpression|>(<getClass>(Q|UExpression|).R|kotlin/jvm/java|<R|UExpression|>)
|
||||
}
|
||||
public final fun <T : R|UExpression|> expressionCapture(clazz: R|java/lang/Class<T>|): R|UExpressionPattern.Capture<T>| {
|
||||
^expressionCapture Q|UExpressionPattern|.R|SubstitutionOverride</UExpressionPattern.Capture.Capture>|<R|T|>(R|<local>/clazz|)
|
||||
}
|
||||
public open class UElementPattern<T : R|UElement|, Self : R|UElementPattern<T, Self>|> : R|ObjectPattern<T, Self>| {
|
||||
public constructor<T : R|UElement|, Self : R|UElementPattern<T, Self>|>(clazz: R|java/lang/Class<T>|): R|UElementPattern<T, Self>| {
|
||||
super<R|ObjectPattern<T, Self>|>(R|<local>/clazz|)
|
||||
}
|
||||
|
||||
public final fun filter(filter: R|(T) -> kotlin/Boolean|): R|Self| {
|
||||
^filter (this@R|/UElementPattern| as R|Self|)
|
||||
}
|
||||
|
||||
}
|
||||
public open class UExpressionPattern<T : R|UExpression|, Self : R|UExpressionPattern<T, Self>|> : R|UElementPattern<T, Self>| {
|
||||
public constructor<T : R|UExpression|, Self : R|UExpressionPattern<T, Self>|>(clazz: R|java/lang/Class<T>|): R|UExpressionPattern<T, Self>| {
|
||||
super<R|UElementPattern<T, Self>|>(R|<local>/clazz|)
|
||||
}
|
||||
|
||||
public open class Capture<T : R|UExpression|> : R|UExpressionPattern<T, ObjectPattern.Capture<T>>| {
|
||||
public constructor<T : R|UExpression|>(clazz: R|java/lang/Class<T>|): R|UExpressionPattern.Capture<T>| {
|
||||
super<R|UExpressionPattern<T, ObjectPattern.Capture<T>>|>(R|<local>/clazz|)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// FILE: ObjectPattern.java
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class ObjectPattern<T, Self extends ObjectPattern<T, Self>> {
|
||||
protected ObjectPattern(@NotNull Class<T> aClass) {
|
||||
|
||||
}
|
||||
|
||||
public static class Capture<T> extends ObjectPattern<T,Capture<T>> {
|
||||
public Capture(@NotNull Class<T> aClass) {
|
||||
super(aClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: UastPatterns.kt
|
||||
|
||||
interface UElement
|
||||
|
||||
interface UExpression : UElement
|
||||
|
||||
interface UReferenceExpression : UExpression
|
||||
|
||||
fun injectionHostOrReferenceExpression(): UExpressionPattern.Capture<UExpression> =
|
||||
<!RETURN_TYPE_MISMATCH, TYPE_MISMATCH!>uExpression().filter { it is UReferenceExpression }<!>
|
||||
|
||||
fun uExpression(): UExpressionPattern.Capture<UExpression> = expressionCapture(UExpression::class.java)
|
||||
|
||||
fun <T : UExpression> expressionCapture(clazz: Class<T>): UExpressionPattern.Capture<T> = UExpressionPattern.Capture(clazz)
|
||||
|
||||
open class UElementPattern<T : UElement, Self : UElementPattern<T, Self>>(clazz: Class<T>) : ObjectPattern<T, Self>(clazz) {
|
||||
fun filter(filter: (T) -> Boolean): Self = this as Self
|
||||
}
|
||||
|
||||
open class UExpressionPattern<T : UExpression, Self : UExpressionPattern<T, Self>>(clazz: Class<T>) : UElementPattern<T, Self>(clazz) {
|
||||
open class Capture<T : UExpression>(clazz: Class<T>) : UExpressionPattern<T, <!UPPER_BOUND_VIOLATED!>Capture<T><!>>(<!ARGUMENT_TYPE_MISMATCH!>clazz<!>)
|
||||
}
|
||||
+6
@@ -5044,6 +5044,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
public void testEnumWithToString() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/EnumWithToString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("UastPatterns.kt")
|
||||
public void testUastPatterns() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/UastPatterns.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -5044,6 +5044,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
public void testEnumWithToString() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/EnumWithToString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("UastPatterns.kt")
|
||||
public void testUastPatterns() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/UastPatterns.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -5044,6 +5044,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
public void testEnumWithToString() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/EnumWithToString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("UastPatterns.kt")
|
||||
public void testUastPatterns() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/UastPatterns.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user