Forbid ExtensionFunctionType on functional types without parameters

#KT-43527 Fixed
This commit is contained in:
Mikhail Glukhikh
2022-01-11 16:42:35 +03:00
parent beb2957726
commit d0fa3eb1d3
14 changed files with 86 additions and 13 deletions
@@ -0,0 +1,20 @@
// WITH_STDLIB
// This test checks that annotations on extension function types are preserved. See the corresponding .txt file
@Target(AnnotationTarget.TYPE)
annotation class ann
interface Some {
fun f1(): String.() -> Int
fun f2(): @ExtensionFunctionType() (String.() -> Int)
fun f3(): @ann String.() -> Int
fun f4(): @ExtensionFunctionType @ann() (String.() -> Int)
fun f5(): <!WRONG_EXTENSION_FUNCTION_TYPE!>@ExtensionFunctionType<!> () -> Int
fun f6(x: <!WRONG_EXTENSION_FUNCTION_TYPE!>@ExtensionFunctionType<!> () -> Int) {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(x <!UNRESOLVED_REFERENCE!>+<!> 2)
}
fun f7(x: <!WRONG_EXTENSION_FUNCTION_TYPE!>@ExtensionFunctionType<!> Function0<Int>)
}
@@ -1,4 +1,4 @@
// FIR_IDENTICAL
// WITH_STDLIB
// This test checks that annotations on extension function types are preserved. See the corresponding .txt file
@Target(AnnotationTarget.TYPE)
@@ -9,4 +9,12 @@ interface Some {
fun f2(): @ExtensionFunctionType() (String.() -> Int)
fun f3(): @ann String.() -> Int
fun f4(): @ExtensionFunctionType @ann() (String.() -> Int)
fun f5(): <!WRONG_EXTENSION_FUNCTION_TYPE!>@ExtensionFunctionType<!> () -> Int
fun f6(x: <!WRONG_EXTENSION_FUNCTION_TYPE!>@ExtensionFunctionType<!> () -> Int) {
println(x <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>+<!> 2)
}
fun f7(x: <!WRONG_EXTENSION_FUNCTION_TYPE!>@ExtensionFunctionType<!> Function0<Int>)
}
@@ -6,6 +6,9 @@ public interface Some {
public abstract fun f2(): kotlin.String.() -> kotlin.Int
public abstract fun f3(): @ann() (kotlin.String.() -> kotlin.Int)
public abstract fun f4(): @ann() (kotlin.String.() -> kotlin.Int)
public abstract fun f5(): kotlin.Int.(???) -> kotlin.Int
public open fun f6(/*0*/ x: kotlin.Int.(???) -> kotlin.Int): kotlin.Unit
public abstract fun f7(/*0*/ x: kotlin.Int.(???) -> kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}