Rename Extension annotation to ExtensionFunctionType
The old one is kept temporarily and will be removed later
This commit is contained in:
+5
-1
@@ -483,10 +483,14 @@ public abstract class Enum</*0*/ E : kotlin.Enum<E>> : kotlin.Comparable<E> {
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.MustBeDocumented() public final annotation class Extension : kotlin.Annotation {
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.MustBeDocumented() @kotlin.Deprecated(message = "Use @ExtensionFunctionType instead.", replaceWith = kotlin.ReplaceWith(expression = "@ExtensionFunctionType", imports = {})) public final annotation class Extension : kotlin.Annotation {
|
||||
/*primary*/ public constructor Extension()
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.MustBeDocumented() public final annotation class ExtensionFunctionType : kotlin.Annotation {
|
||||
/*primary*/ public constructor ExtensionFunctionType()
|
||||
}
|
||||
|
||||
public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> {
|
||||
/*primary*/ private constructor Float()
|
||||
public final operator fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int
|
||||
|
||||
@@ -6,7 +6,7 @@ fun foo(<!UNUSED_PARAMETER!>a<!>: (String) -> Unit) {
|
||||
|
||||
interface A : (String) -> Unit {}
|
||||
|
||||
fun foo(<!UNUSED_PARAMETER!>a<!>: @Extension A) {
|
||||
fun foo(<!UNUSED_PARAMETER!>a<!>: @ExtensionFunctionType A) {
|
||||
// @Extension annotation on an unrelated type shouldn't have any effect on this diagnostic.
|
||||
// Only kotlin.Function{n} type annotated with @Extension should
|
||||
"".<!UNRESOLVED_REFERENCE!>a<!>()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ a: (kotlin.String) -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ a: @kotlin.Extension() A): kotlin.Unit
|
||||
public fun foo(/*0*/ a: @kotlin.ExtensionFunctionType() A): kotlin.Unit
|
||||
|
||||
public interface A : (kotlin.String) -> kotlin.Unit {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
@@ -5,7 +5,7 @@ annotation class ann
|
||||
|
||||
interface Some {
|
||||
fun f1(): String.() -> Int
|
||||
fun f2(): @Extension String.() -> Int
|
||||
fun f2(): @ExtensionFunctionType String.() -> Int
|
||||
fun f3(): @ann String.() -> Int
|
||||
fun f4(): @Extension @ann String.() -> Int
|
||||
fun f4(): @ExtensionFunctionType @ann String.() -> Int
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package
|
||||
public interface Some {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun f1(): kotlin.String.() -> kotlin.Int
|
||||
public abstract fun f2(): @kotlin.Extension() kotlin.String.() -> kotlin.Int
|
||||
public abstract fun f2(): @kotlin.ExtensionFunctionType() kotlin.String.() -> kotlin.Int
|
||||
public abstract fun f3(): @ann() kotlin.String.() -> kotlin.Int
|
||||
public abstract fun f4(): @kotlin.Extension() @ann() kotlin.String.() -> kotlin.Int
|
||||
public abstract fun f4(): @kotlin.ExtensionFunctionType() @ann() kotlin.String.() -> kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ operator fun <T, U, V> Function2<T, U, V>.get(index : Int) {
|
||||
|
||||
}
|
||||
|
||||
operator fun <T, U, V, W> @Extension Function3<T, U, V, W>.get(index : Int) {
|
||||
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.get(index : Int) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ inline operator fun <T, U> Function1<T, U>.plusAssign(p: Function1<T, U>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>p<!> -= <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}
|
||||
|
||||
operator fun <T, U, V> @Extension Function2<T, U, V>.minusAssign(ext : @Extension Function2<T, U, V>) {}
|
||||
operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.minusAssign(ext : @ExtensionFunctionType Function2<T, U, V>) {}
|
||||
|
||||
inline <!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun <T, U, V> @Extension Function2<T, U, V>.modAssign(ext : @Extension Function2<T, U, V>) = {
|
||||
inline <!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.modAssign(ext : @ExtensionFunctionType Function2<T, U, V>) = {
|
||||
this += ext
|
||||
ext += this
|
||||
}
|
||||
|
||||
inline operator fun <T, U, V> @Extension Function2<T, U, V>.plusAssign(ext : @Extension Function2<T, U, V>) {
|
||||
inline operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.plusAssign(ext : @ExtensionFunctionType Function2<T, U, V>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> -= <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> -= <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
|
||||
|
||||
//noinline
|
||||
operator fun <T, U, V> Function2<T, U, V>.compareTo(index : Function2<T, U, V>) = 1
|
||||
operator fun <T, U, V, W> @Extension Function3<T, U, V, W>.compareTo(index : @Extension Function3<T, U, V, W>) = 1
|
||||
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.compareTo(index : @ExtensionFunctionType Function3<T, U, V, W>) = 1
|
||||
|
||||
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> < <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
|
||||
operator fun <T, U, V> Function2<T, U, V>.component1() = 1
|
||||
operator fun <T, U, V> Function2<T, U, V>.component2() = 2
|
||||
|
||||
operator fun <T, U, V, W> @Extension Function3<T, U, V, W>.component1() = 1
|
||||
operator fun <T, U, V, W> @Extension Function3<T, U, V, W>.component2() = 2
|
||||
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.component1() = 1
|
||||
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.component2() = 2
|
||||
|
||||
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
|
||||
val (d1, e1) = <!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
@@ -13,7 +13,7 @@ inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
|
||||
|
||||
operator fun <T, U, V> Function2<T, U, V>.contains(p: Function2<T, U, V>): Boolean = false
|
||||
|
||||
operator fun <T, U, V, W> @Extension Function3<T, U, V, W>.contains(ext: @Extension Function3<T, U, V, W>): Boolean = false
|
||||
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.contains(ext: @ExtensionFunctionType Function3<T, U, V, W>): Boolean = false
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T, l: U) -> U, ext: T.(p: U, l: U) -> V) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> in <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ operator fun <T, U> Function1<T, U>.minus(p: Function1<T, U>) {
|
||||
|
||||
}
|
||||
|
||||
operator fun <T, U, V> @Extension Function2<T, U, V>.minus(p: T.(p: U) -> V) {
|
||||
operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.minus(p: T.(p: U) -> V) {
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ inline operator fun <T, U> Function1<T, U>.plus(p: Function1<T, U>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> - <!USAGE_IS_NOT_INLINABLE!>p<!>
|
||||
}
|
||||
|
||||
inline operator fun <T, U, V> @Extension Function2<T, U, V>.plus(p: T.(p: U) -> V) {
|
||||
inline operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.plus(p: T.(p: U) -> V) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> - <!USAGE_IS_NOT_INLINABLE!>p<!>
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ inline fun <T, U> Function1<T, U>.submit() {
|
||||
this + this
|
||||
}
|
||||
|
||||
inline fun <T, U, V> @Extension Function2<T, U, V>.submit() {
|
||||
inline fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.submit() {
|
||||
this + this
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ operator fun <T, U, V> Function2<T, U, V>.rangeTo(p: Function2<T, U, V>): Closed
|
||||
return 1..2
|
||||
}
|
||||
|
||||
operator fun <T, U, V, W> @Extension Function3<T, U, V, W>.rangeTo(ext: @Extension Function3<T, U, V, W>): ClosedRange<Int> {
|
||||
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.rangeTo(ext: @ExtensionFunctionType Function3<T, U, V, W>): ClosedRange<Int> {
|
||||
return 1..2
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -5,10 +5,10 @@ operator fun <T, V> Function1<T, V>.unaryMinus() = this
|
||||
inline operator fun <T, V> Function1<T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
operator fun <T, V> Function1<T, V>.dec() = this
|
||||
|
||||
inline operator fun <T, V> @Extension Function2<T, T, V>.unaryPlus(){}
|
||||
operator fun <T, V> @Extension Function2<T, T, V>.unaryMinus(){}
|
||||
inline operator fun <T, V> @Extension Function2<T, T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
operator fun <T, V> @Extension Function2<T, T, V>.dec() = this
|
||||
inline operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.unaryPlus(){}
|
||||
operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.unaryMinus(){}
|
||||
inline operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.dec() = this
|
||||
|
||||
inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V, ext: T.(p: T) -> V) {
|
||||
+s
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ operator fun <T, U, V> Function2<T, U, V>.not() : Boolean {
|
||||
return !this
|
||||
}
|
||||
|
||||
operator fun <T, U, V, W> @Extension Function3<T, U, V, W>.not() : Boolean {
|
||||
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.not() : Boolean {
|
||||
return !this
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -5,18 +5,18 @@ var v4: Function1<Int, String>
|
||||
var v4: (() -> Int, (String) -> Unit) -> String
|
||||
var v5: Int.() -> Int
|
||||
var v6 : Int.(String, Int) -> Unit
|
||||
var v7 : @Extension Function2<Int, String, Boolean>
|
||||
var v7 : @ExtensionFunctionType Function2<Int, String, Boolean>
|
||||
|
||||
class F: Function0<Unit>
|
||||
var v8: F
|
||||
|
||||
class EF: @Extension Function1<String, Unit>
|
||||
class EF: @ExtensionFunctionType Function1<String, Unit>
|
||||
var v9: EF
|
||||
|
||||
class GF<T>: Function0<T>
|
||||
var v10: GF<Any>
|
||||
|
||||
class GEF<A, B>: @Extension Function1<A, B>
|
||||
class GEF<A, B>: @ExtensionFunctionType Function1<A, B>
|
||||
var v11: GEF<Any, Any>
|
||||
|
||||
var v12: (() -> Unit).() -> Unit
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ Resolved call:
|
||||
Resulting descriptor: operator fun Int.invoke(): Unit defined in kotlin.Function1
|
||||
|
||||
Explicit receiver kind = BOTH_RECEIVERS
|
||||
Dispatch receiver = f {[@kotlin.Extension] Function1<Int, Unit>}
|
||||
Dispatch receiver = f {[@kotlin.ExtensionFunctionType] Function1<Int, Unit>}
|
||||
Extension receiver = 1 {Int}
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ Resolved call:
|
||||
Resulting descriptor: operator fun Int.invoke(): Unit defined in kotlin.Function1
|
||||
|
||||
Explicit receiver kind = BOTH_RECEIVERS
|
||||
Dispatch receiver = foo {[@kotlin.Extension] Function1<Int, Unit>}
|
||||
Dispatch receiver = foo {[@kotlin.ExtensionFunctionType] Function1<Int, Unit>}
|
||||
Extension receiver = 1 {Int}
|
||||
|
||||
@@ -9,5 +9,5 @@ Resolved call:
|
||||
Resulting descriptor: operator fun Int.invoke(): Unit defined in kotlin.Function1
|
||||
|
||||
Explicit receiver kind = BOTH_RECEIVERS
|
||||
Dispatch receiver = f {[@kotlin.Extension] Function1<Int, Unit>}
|
||||
Dispatch receiver = f {[@kotlin.ExtensionFunctionType] Function1<Int, Unit>}
|
||||
Extension receiver = 1 {Int}
|
||||
|
||||
@@ -11,5 +11,5 @@ Resolved call:
|
||||
Resulting descriptor: operator fun Int.invoke(): Unit defined in kotlin.Function1
|
||||
|
||||
Explicit receiver kind = DISPATCH_RECEIVER
|
||||
Dispatch receiver = f {[@kotlin.Extension] Function1<Int, Unit>}
|
||||
Dispatch receiver = f {[@kotlin.ExtensionFunctionType] Function1<Int, Unit>}
|
||||
Extension receiver = IntExt{fun Int.<anonymous>(): Unit defined in bar}
|
||||
|
||||
@@ -69,6 +69,11 @@ public enum class DeprecationLevel {
|
||||
*/
|
||||
@Target(TYPE)
|
||||
@MustBeDocumented
|
||||
public annotation class ExtensionFunctionType
|
||||
|
||||
@Target(TYPE)
|
||||
@MustBeDocumented
|
||||
@Deprecated("Use @ExtensionFunctionType instead.", replaceWith = ReplaceWith("@ExtensionFunctionType"))
|
||||
public annotation class Extension
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,7 +140,7 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
public final FqName deprecated = fqName("Deprecated");
|
||||
public final FqName deprecationLevel = fqName("DeprecationLevel");
|
||||
public final FqName extension = fqName("Extension");
|
||||
public final FqName extensionFunctionType = fqName("ExtensionFunctionType");
|
||||
public final FqName target = annotationName("Target");
|
||||
public final FqName annotationTarget = annotationName("AnnotationTarget");
|
||||
public final FqName annotationRetention = annotationName("AnnotationRetention");
|
||||
@@ -157,6 +157,9 @@ public abstract class KotlinBuiltIns {
|
||||
public final FqNameUnsafe kCallable = reflect("KCallable");
|
||||
public final ClassId kProperty = ClassId.topLevel(reflect("KProperty").toSafe());
|
||||
|
||||
// TODO: remove in 1.0
|
||||
public final FqName deprecatedExtensionAnnotation = fqName("Extension");
|
||||
|
||||
public final Map<FqNameUnsafe, PrimitiveType> fqNameToPrimitiveType;
|
||||
public final Map<FqNameUnsafe, PrimitiveType> arrayClassFqNameToPrimitiveType;
|
||||
{
|
||||
@@ -709,12 +712,13 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
public AnnotationDescriptor createExtensionAnnotation() {
|
||||
return new AnnotationDescriptorImpl(getBuiltInClassByName(FQ_NAMES.extension.shortName()).getDefaultType(),
|
||||
return new AnnotationDescriptorImpl(getBuiltInClassByName(FQ_NAMES.extensionFunctionType.shortName()).getDefaultType(),
|
||||
Collections.<ValueParameterDescriptor, ConstantValue<?>>emptyMap(), SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
private static boolean isTypeAnnotatedWithExtension(@NotNull KotlinType type) {
|
||||
return type.getAnnotations().findAnnotation(FQ_NAMES.extension) != null;
|
||||
return type.getAnnotations().findAnnotation(FQ_NAMES.extensionFunctionType) != null ||
|
||||
type.getAnnotations().findAnnotation(FQ_NAMES.deprecatedExtensionAnnotation) != null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -728,14 +732,14 @@ public abstract class KotlinBuiltIns {
|
||||
int size = parameterTypes.size();
|
||||
ClassDescriptor classDescriptor = receiverType == null ? getFunction(size) : getExtensionFunction(size);
|
||||
|
||||
Annotations typeAnnotations = receiverType == null ? annotations : addExtensionAnnotation(annotations);
|
||||
Annotations typeAnnotations = receiverType == null ? annotations : addExtensionFunctionTypeAnnotation(annotations);
|
||||
|
||||
return KotlinTypeImpl.create(typeAnnotations, classDescriptor, false, arguments);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Annotations addExtensionAnnotation(@NotNull Annotations annotations) {
|
||||
if (annotations.findAnnotation(FQ_NAMES.extension) != null) return annotations;
|
||||
private Annotations addExtensionFunctionTypeAnnotation(@NotNull Annotations annotations) {
|
||||
if (annotations.findAnnotation(FQ_NAMES.extensionFunctionType) != null) return annotations;
|
||||
|
||||
// TODO: preserve laziness of given annotations
|
||||
return new AnnotationsImpl(plus(annotations, listOf(createExtensionAnnotation())));
|
||||
|
||||
+4
-1
@@ -80,7 +80,10 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
val shouldBuildAsFunctionType = KotlinBuiltIns.isNumberedFunctionClassFqName(classId.asSingleFqName().toUnsafe())
|
||||
&& type.getArgumentList().none { it.getProjection() == Projection.STAR }
|
||||
if (shouldBuildAsFunctionType) {
|
||||
val extension = annotations.any { annotation -> annotation.asSingleFqName() == KotlinBuiltIns.FQ_NAMES.extension }
|
||||
val extension = annotations.any { annotation ->
|
||||
val fqName = annotation.asSingleFqName()
|
||||
fqName == KotlinBuiltIns.FQ_NAMES.extensionFunctionType || fqName == KotlinBuiltIns.FQ_NAMES.deprecatedExtensionAnnotation
|
||||
}
|
||||
createFunctionTypeStub(parent, type, extension)
|
||||
return
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
package somePackage
|
||||
|
||||
class ExcludedClass
|
||||
// Such strange name here needed to make completion prefix not intersecting with kotlin.Extension
|
||||
// Such strange name here needed to make completion prefix not intersecting with kotlin.ExtensionFunctionType
|
||||
class ExctraClass
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
package somePackage;
|
||||
|
||||
// Such strange name here needed to make completion prefix not intersecting with kotlin.Extension
|
||||
// Such strange name here needed to make completion prefix not intersecting with kotlin.ExtensionFunctionType
|
||||
public class ExctraClass {
|
||||
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ fun (() -> Unit)?.helloFun1() {
|
||||
fun Function0<Unit>.helloFun2() {
|
||||
}
|
||||
|
||||
fun @Extension Function1<String, Unit>.helloFun3() {
|
||||
fun @ExtensionFunctionType Function1<String, Unit>.helloFun3() {
|
||||
}
|
||||
|
||||
fun Function1<String, Unit>.helloFun4() {
|
||||
|
||||
+2
-2
@@ -6,10 +6,10 @@ fun (String.() -> Unit)?.helloFun1() {
|
||||
fun Function0<Unit>.helloFun2() {
|
||||
}
|
||||
|
||||
fun @Extension Function1<String, Unit>.helloFun3() {
|
||||
fun @ExtensionFunctionType Function1<String, Unit>.helloFun3() {
|
||||
}
|
||||
|
||||
fun @Extension Function1<Int, Unit>.helloFun4() {
|
||||
fun @ExtensionFunctionType Function1<Int, Unit>.helloFun4() {
|
||||
}
|
||||
|
||||
fun Function1<String, Unit>.helloFun5() {
|
||||
|
||||
@@ -10,7 +10,7 @@ public final class FunctionTypes public constructor() {
|
||||
|
||||
public final fun f3(f: kotlin.Int.(kotlin.Int) -> kotlin.Unit): kotlin.Unit { /* compiled code */ }
|
||||
|
||||
public final fun f4(f: kotlin.List<@kotlin.Extension kotlin.Function1<*, *>>): kotlin.Unit { /* compiled code */ }
|
||||
public final fun f4(f: kotlin.List<@kotlin.ExtensionFunctionType kotlin.Function1<*, *>>): kotlin.Unit { /* compiled code */ }
|
||||
|
||||
public final fun <A> (A.(A) -> A)?.bar(): kotlin.Unit { /* compiled code */ }
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ class FunctionTypes {
|
||||
public fun f2(f: Function2<Int, *, String>) {
|
||||
}
|
||||
|
||||
public fun f3(f: @Extension Function2<Int, Int, Unit>) {
|
||||
public fun f3(f: @ExtensionFunctionType Function2<Int, Int, Unit>) {
|
||||
}
|
||||
|
||||
public fun f4(f: List<@Extension Function1<*, *>>) {
|
||||
public fun f4(f: List<@ExtensionFunctionType Function1<*, *>>) {
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ abstract class Types {
|
||||
|
||||
abstract val starList: List<*>
|
||||
abstract val starFun: Function1<*, *>
|
||||
abstract val extFun: @Extension Function2<Int, Int, Unit>
|
||||
abstract val listExtStarFun: List<@Extension Function1<*, *>>
|
||||
abstract val extFun: @ExtensionFunctionType Function2<Int, Int, Unit>
|
||||
abstract val listExtStarFun: List<@ExtensionFunctionType Function1<*, *>>
|
||||
abstract val funTypeWithStarAndNonStar: Function1<*, Int>
|
||||
}
|
||||
+2
-2
@@ -252,13 +252,13 @@ PsiJetFileStubImpl[package=test]
|
||||
TYPE_ARGUMENT_LIST:
|
||||
TYPE_PROJECTION:[projectionKind=NONE]
|
||||
TYPE_REFERENCE:
|
||||
ANNOTATION_ENTRY:[hasValueArguments=false, shortName=Extension]
|
||||
ANNOTATION_ENTRY:[hasValueArguments=false, shortName=ExtensionFunctionType]
|
||||
CONSTRUCTOR_CALLEE:
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:[isAbsoluteInRootPackage=false]
|
||||
USER_TYPE:[isAbsoluteInRootPackage=false]
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Extension]
|
||||
REFERENCE_EXPRESSION:[referencedName=ExtensionFunctionType]
|
||||
USER_TYPE:[isAbsoluteInRootPackage=false]
|
||||
USER_TYPE:[isAbsoluteInRootPackage=false]
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ val c: <selection>() -> String</selection> = { "" }
|
||||
val d: () -> kotlin.String = { "" }
|
||||
val e: () -> Unit = { }
|
||||
val f: Any.() -> String = { "" }
|
||||
val g: @Extension Function1<String, String> = { "" }
|
||||
val g: @ExtensionFunctionType Function1<String, String> = { "" }
|
||||
|
||||
+2
-2
@@ -5,6 +5,6 @@ val d: (n: Int) -> kotlin.String = { "" }
|
||||
val e: (String) -> Int = { 0 }
|
||||
val f: () -> Int = { 0 }
|
||||
val g: Int.() -> String = { "" }
|
||||
val h: @Extension Function2<Int, Int, String> = { "" }
|
||||
val h: @ExtensionFunctionType Function2<Int, Int, String> = { "" }
|
||||
val i: (m: Int) -> kotlin.String = { "" }
|
||||
val j: @Extension Function1<Int, String> = { "" }
|
||||
val j: @ExtensionFunctionType Function1<Int, String> = { "" }
|
||||
|
||||
@@ -10,4 +10,4 @@ Int.() -> String
|
||||
|
||||
(m: Int) -> kotlin.String
|
||||
|
||||
@Extension Function1<Int, String>
|
||||
@ExtensionFunctionType Function1<Int, String>
|
||||
|
||||
+2
-2
@@ -6,6 +6,6 @@ val e: (String) -> Int = { 0 }
|
||||
val f: () -> Int = { 0 }
|
||||
val g: Any.(Int) -> String = { "" }
|
||||
val h: Int.(Any) -> String = { "" }
|
||||
val i: @Extension Function3<Any, Any, Int, String> = { a, b -> "" }
|
||||
val i: @ExtensionFunctionType Function3<Any, Any, Int, String> = { a, b -> "" }
|
||||
val j: (t: Any, u: Int) -> kotlin.String = { a, b -> "" }
|
||||
val k: @Extension Function2<Any, Int, String> = { "" }
|
||||
val k: @ExtensionFunctionType Function2<Any, Int, String> = { "" }
|
||||
|
||||
@@ -10,4 +10,4 @@ Any.(Int) -> String
|
||||
|
||||
(t: Any, u: Int) -> kotlin.String
|
||||
|
||||
@Extension Function2<Any, Int, String>
|
||||
@ExtensionFunctionType Function2<Any, Int, String>
|
||||
|
||||
@@ -23,7 +23,7 @@ Kotlin lambdas are translated to subclasses of this abstract class, passing the
|
||||
|
||||
## Extension functions
|
||||
|
||||
Extension function type `T.(P) -> R` is now just a shorthand for `@Extension Function2<T, P, R>`.
|
||||
Extension function type `T.(P) -> R` is now just a shorthand for `@ExtensionFunctionType Function2<T, P, R>`.
|
||||
`kotlin.extension` is a **type annotation** defined in built-ins.
|
||||
So effectively functions and extension functions now have the same type,
|
||||
which means that everything which takes a function will work with an extension function and vice versa.
|
||||
@@ -40,7 +40,7 @@ or an extension function expression where a function is expected and vice versa.
|
||||
If you really want to do that, change the shape, assign literal to a variable or use the `as` operator.
|
||||
|
||||
So basically you can now safely coerce values between function and extension function types,
|
||||
but still should invoke them in the format which you specified in their type (with or without `@Extension`).
|
||||
but still should invoke them in the format which you specified in their type (with or without `@ExtensionFunctionType`).
|
||||
|
||||
With this we'll get rid of classes `ExtensionFunction0`, `ExtensionFunction1`, ...
|
||||
and the rest of this article will deal only with usual functions.
|
||||
|
||||
Reference in New Issue
Block a user