Deprecate extension annotation in favor of Extension

This commit is contained in:
Denis Zharkov
2015-09-01 13:44:02 +03:00
parent 3597234165
commit 11fed1674e
36 changed files with 72 additions and 71 deletions
+4 -4
View File
@@ -427,6 +427,10 @@ public abstract class Enum</*0*/ E : kotlin.Enum<E>> : kotlin.Comparable<E> {
} }
} }
kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation(mustBeDocumented = true) public final class Extension : kotlin.Annotation {
/*primary*/ public constructor Extension()
}
public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> { public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> {
/*primary*/ private constructor Float() /*primary*/ private constructor Float()
public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int
@@ -1262,10 +1266,6 @@ kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, Annotati
internal final fun <get-value>(): kotlin.String internal final fun <get-value>(): kotlin.String
} }
kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation(mustBeDocumented = true) public final class extension : kotlin.Annotation {
/*primary*/ public constructor extension()
}
kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) kotlin.annotation.annotation(mustBeDocumented = true, retention = AnnotationRetention.RUNTIME) public final class inline : kotlin.Annotation { kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) kotlin.annotation.annotation(mustBeDocumented = true, retention = AnnotationRetention.RUNTIME) public final class inline : kotlin.Annotation {
/*primary*/ public constructor inline(/*0*/ strategy: kotlin.InlineStrategy = ...) /*primary*/ public constructor inline(/*0*/ strategy: kotlin.InlineStrategy = ...)
public final val strategy: kotlin.InlineStrategy public final val strategy: kotlin.InlineStrategy
+3 -3
View File
@@ -11,9 +11,9 @@ fun test1() {
} }
fun test2() { fun test2() {
val a: (@extension Function2<*, *, *>).(@extension Function2<*, *, *>)->Unit = {} val a: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->Unit = {}
val b: (@extension Function2<*, *, *>).(@extension Function2<*, *, *>)->Unit = {"$this $it"} val b: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->Unit = {"$this $it"}
val c: (@extension Function2<*, *, *>).(@extension Function2<*, *, *>)->Unit = {} val c: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->Unit = {}
a.b(c) a.b(c)
a b c a b c
} }
@@ -6,8 +6,8 @@ fun foo(a: (String) -> Unit) {
interface A : (String) -> Unit {} interface A : (String) -> Unit {}
fun foo(a: @extension A) { fun foo(a: @Extension A) {
// @extension annotation on an unrelated type shouldn't have any effect on this diagnostic. // @Extension annotation on an unrelated type shouldn't have any effect on this diagnostic.
// Only kotlin.Function{n} type annotated with @extension should // Only kotlin.Function{n} type annotated with @Extension should
"".<!FREE_FUNCTION_CALLED_AS_EXTENSION!>a<!>() "".<!FREE_FUNCTION_CALLED_AS_EXTENSION!>a<!>()
} }
@@ -1,7 +1,7 @@
package package
internal fun foo(/*0*/ a: (kotlin.String) -> kotlin.Unit): kotlin.Unit internal fun foo(/*0*/ a: (kotlin.String) -> kotlin.Unit): kotlin.Unit
internal fun foo(/*0*/ a: @[kotlin.extension()] A): kotlin.Unit internal fun foo(/*0*/ a: @[kotlin.Extension()] A): kotlin.Unit
internal interface A : (kotlin.String) -> kotlin.Unit { internal interface A : (kotlin.String) -> kotlin.Unit {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@@ -4,7 +4,7 @@ annotation class ann
interface Some { interface Some {
fun f1(): String.() -> Int fun f1(): String.() -> Int
fun f2(): @extension String.() -> Int fun f2(): @Extension String.() -> Int
fun f3(): @ann String.() -> Int fun f3(): @ann String.() -> Int
fun f4(): @extension @ann String.() -> Int fun f4(): @Extension @ann String.() -> Int
} }
@@ -3,9 +3,9 @@ package
internal interface Some { internal interface Some {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal abstract fun f1(): kotlin.String.() -> kotlin.Int internal abstract fun f1(): kotlin.String.() -> kotlin.Int
internal abstract fun f2(): @[kotlin.extension()] kotlin.String.() -> kotlin.Int internal abstract fun f2(): @[kotlin.Extension()] kotlin.String.() -> kotlin.Int
internal abstract fun f3(): @[ann()] kotlin.String.() -> kotlin.Int internal abstract fun f3(): @[ann()] kotlin.String.() -> kotlin.Int
internal abstract fun f4(): @[kotlin.extension() ann()] kotlin.String.() -> kotlin.Int internal abstract fun f4(): @[kotlin.Extension() ann()] kotlin.String.() -> kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -12,7 +12,7 @@ fun <T, U, V> Function2<T, U, V>.get(index : Int) {
} }
fun <T, U, V, W> @extension Function3<T, U, V, W>.get(index : Int) { fun <T, U, V, W> @Extension Function3<T, U, V, W>.get(index : Int) {
} }
@@ -12,14 +12,14 @@ inline fun <T, U> Function1<T, U>.plusAssign(p: Function1<T, U>) {
<!USAGE_IS_NOT_INLINABLE!>p<!> -= <!USAGE_IS_NOT_INLINABLE!>this<!> <!USAGE_IS_NOT_INLINABLE!>p<!> -= <!USAGE_IS_NOT_INLINABLE!>this<!>
} }
fun <T, U, V> @extension Function2<T, U, V>.minusAssign(ext : @extension Function2<T, U, V>) {} fun <T, U, V> @Extension Function2<T, U, V>.minusAssign(ext : @Extension Function2<T, U, V>) {}
inline fun <T, U, V> @extension Function2<T, U, V>.modAssign(ext : @extension Function2<T, U, V>) = { inline fun <T, U, V> @Extension Function2<T, U, V>.modAssign(ext : @Extension Function2<T, U, V>) = {
this += ext this += ext
ext += this ext += this
} }
inline fun <T, U, V> @extension Function2<T, U, V>.plusAssign(ext : @extension Function2<T, U, V>) { inline fun <T, U, V> @Extension Function2<T, U, V>.plusAssign(ext : @Extension Function2<T, U, V>) {
<!USAGE_IS_NOT_INLINABLE!>this<!> -= <!USAGE_IS_NOT_INLINABLE!>ext<!> <!USAGE_IS_NOT_INLINABLE!>this<!> -= <!USAGE_IS_NOT_INLINABLE!>ext<!>
<!USAGE_IS_NOT_INLINABLE!>ext<!> -= <!USAGE_IS_NOT_INLINABLE!>this<!> <!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 //noinline
fun <T, U, V> Function2<T, U, V>.compareTo(index : Function2<T, U, V>) = 1 fun <T, U, V> Function2<T, U, V>.compareTo(index : Function2<T, U, V>) = 1
fun <T, U, V, W> @extension Function3<T, U, V, W>.compareTo(index : @extension Function3<T, U, V, W>) = 1 fun <T, U, V, W> @Extension Function3<T, U, V, W>.compareTo(index : @Extension 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) { 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<!> <!USAGE_IS_NOT_INLINABLE!>s<!> < <!USAGE_IS_NOT_INLINABLE!>s<!>
@@ -9,8 +9,8 @@ inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
fun <T, U, V> Function2<T, U, V>.component1() = 1 fun <T, U, V> Function2<T, U, V>.component1() = 1
fun <T, U, V> Function2<T, U, V>.component2() = 2 fun <T, U, V> Function2<T, U, V>.component2() = 2
fun <T, U, V, W> @extension Function3<T, U, V, W>.component1() = 1 fun <T, U, V, W> @Extension Function3<T, U, V, W>.component1() = 1
fun <T, U, V, W> @extension Function3<T, U, V, W>.component2() = 2 fun <T, U, V, W> @Extension 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) { 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<!> 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) {
fun <T, U, V> Function2<T, U, V>.contains(p: Function2<T, U, V>): Boolean = false fun <T, U, V> Function2<T, U, V>.contains(p: Function2<T, U, V>): Boolean = false
fun <T, U, V, W> @extension Function3<T, U, V, W>.contains(ext: @extension Function3<T, U, V, W>): Boolean = false fun <T, U, V, W> @Extension Function3<T, U, V, W>.contains(ext: @Extension 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) { 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<!> <!USAGE_IS_NOT_INLINABLE!>s<!> in <!USAGE_IS_NOT_INLINABLE!>s<!>
@@ -3,7 +3,7 @@ fun <T, U> Function1<T, U>.minus(p: Function1<T, U>) {
} }
fun <T, U, V> @extension Function2<T, U, V>.minus(p: T.(p: U) -> V) { fun <T, U, V> @Extension Function2<T, U, V>.minus(p: T.(p: U) -> V) {
} }
@@ -11,7 +11,7 @@ inline fun <T, U> Function1<T, U>.plus(p: Function1<T, U>) {
<!USAGE_IS_NOT_INLINABLE!>this<!> - <!USAGE_IS_NOT_INLINABLE!>p<!> <!USAGE_IS_NOT_INLINABLE!>this<!> - <!USAGE_IS_NOT_INLINABLE!>p<!>
} }
inline fun <T, U, V> @extension Function2<T, U, V>.plus(p: T.(p: U) -> V) { inline fun <T, U, V> @Extension Function2<T, U, V>.plus(p: T.(p: U) -> V) {
<!USAGE_IS_NOT_INLINABLE!>this<!> - <!USAGE_IS_NOT_INLINABLE!>p<!> <!USAGE_IS_NOT_INLINABLE!>this<!> - <!USAGE_IS_NOT_INLINABLE!>p<!>
} }
@@ -29,6 +29,6 @@ inline fun <T, U> Function1<T, U>.submit() {
this + this this + this
} }
inline fun <T, U, V> @extension Function2<T, U, V>.submit() { inline fun <T, U, V> @Extension Function2<T, U, V>.submit() {
this + this this + this
} }
@@ -16,7 +16,7 @@ fun <T, U, V> Function2<T, U, V>.rangeTo(p: Function2<T, U, V>): Range<Int> {
return 1..2 return 1..2
} }
fun <T, U, V, W> @extension Function3<T, U, V, W>.rangeTo(ext: @extension Function3<T, U, V, W>): Range<Int> { fun <T, U, V, W> @Extension Function3<T, U, V, W>.rangeTo(ext: @Extension Function3<T, U, V, W>): Range<Int> {
return 1..2 return 1..2
} }
@@ -5,10 +5,10 @@ fun <T, V> Function1<T, V>.minus() = this
inline fun <T, V> Function1<T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!> inline fun <T, V> Function1<T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!>
fun <T, V> Function1<T, V>.dec() = this fun <T, V> Function1<T, V>.dec() = this
inline fun <T, V> @extension Function2<T, T, V>.plus(){} inline fun <T, V> @Extension Function2<T, T, V>.plus(){}
fun <T, V> @extension Function2<T, T, V>.minus(){} fun <T, V> @Extension Function2<T, T, V>.minus(){}
inline fun <T, V> @extension Function2<T, T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!> inline fun <T, V> @Extension Function2<T, T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!>
fun <T, V> @extension Function2<T, T, V>.dec() = this fun <T, V> @Extension Function2<T, T, V>.dec() = this
inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V, ext: T.(p: T) -> V) { inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V, ext: T.(p: T) -> V) {
+s +s
@@ -11,7 +11,7 @@ fun <T, U, V> Function2<T, U, V>.not() : Boolean {
return !this return !this
} }
fun <T, U, V, W> @extension Function3<T, U, V, W>.not() : Boolean { fun <T, U, V, W> @Extension Function3<T, U, V, W>.not() : Boolean {
return !this return !this
} }
+3 -3
View File
@@ -5,18 +5,18 @@ var v4: Function1<Int, String>
var v4: (() -> Int, (String) -> Unit) -> String var v4: (() -> Int, (String) -> Unit) -> String
var v5: Int.() -> Int var v5: Int.() -> Int
var v6 : Int.(String, Int) -> Unit var v6 : Int.(String, Int) -> Unit
var v7 : @extension Function2<Int, String, Boolean> var v7 : @Extension Function2<Int, String, Boolean>
class F: Function0<Unit> class F: Function0<Unit>
var v8: F var v8: F
class EF: @extension Function1<String, Unit> class EF: @Extension Function1<String, Unit>
var v9: EF var v9: EF
class GF<T>: Function0<T> class GF<T>: Function0<T>
var v10: GF<Any> var v10: GF<Any>
class GEF<A, B>: @extension Function1<A, B> class GEF<A, B>: @Extension Function1<A, B>
var v11: GEF<Any, Any> var v11: GEF<Any, Any>
var v12: (() -> Unit).() -> Unit var v12: (() -> Unit).() -> Unit
@@ -8,5 +8,5 @@ Resolved call:
Resulting descriptor: fun Int.invoke(): Unit defined in kotlin.Function1 Resulting descriptor: fun Int.invoke(): Unit defined in kotlin.Function1
Explicit receiver kind = BOTH_RECEIVERS Explicit receiver kind = BOTH_RECEIVERS
Dispatch receiver = f {[kotlin.extension] Function1<Int, Unit>} Dispatch receiver = f {[kotlin.Extension] Function1<Int, Unit>}
Extension receiver = 1 {Int} Extension receiver = 1 {Int}
@@ -12,5 +12,5 @@ Resolved call:
Resulting descriptor: fun Int.invoke(): Unit defined in kotlin.Function1 Resulting descriptor: fun Int.invoke(): Unit defined in kotlin.Function1
Explicit receiver kind = BOTH_RECEIVERS Explicit receiver kind = BOTH_RECEIVERS
Dispatch receiver = foo {[kotlin.extension] Function1<Int, Unit>} Dispatch receiver = foo {[kotlin.Extension] Function1<Int, Unit>}
Extension receiver = 1 {Int} Extension receiver = 1 {Int}
+1 -1
View File
@@ -59,7 +59,7 @@ public annotation(retention = BINARY, mustBeDocumented = true) class ReplaceWith
* Signifies that the annotated functional type represents an extension function. * Signifies that the annotated functional type represents an extension function.
*/ */
target(TYPE) target(TYPE)
public annotation(mustBeDocumented = true) class extension public annotation(mustBeDocumented = true) class Extension
/** /**
* Suppresses the given compilation warnings in the annotated element. * Suppresses the given compilation warnings in the annotated element.
@@ -175,7 +175,7 @@ public class KotlinBuiltIns {
public final FqName inline = fqName("inline"); public final FqName inline = fqName("inline");
public final FqName noinline = fqName("noinline"); public final FqName noinline = fqName("noinline");
public final FqName inlineOptions = fqName("inlineOptions"); public final FqName inlineOptions = fqName("inlineOptions");
public final FqName extension = fqName("extension"); public final FqName extension = fqName("Extension");
public final FqName target = annotationName("target"); public final FqName target = annotationName("target");
public final FqName annotation = annotationName("annotation"); public final FqName annotation = annotationName("annotation");
public final FqName annotationTarget = annotationName("AnnotationTarget"); public final FqName annotationTarget = annotationName("AnnotationTarget");
@@ -721,7 +721,7 @@ public class KotlinBuiltIns {
@NotNull @NotNull
public AnnotationDescriptor createExtensionAnnotation() { public AnnotationDescriptor createExtensionAnnotation() {
return new AnnotationDescriptorImpl(getBuiltInClassByName("extension").getDefaultType(), return new AnnotationDescriptorImpl(getBuiltInClassByName(FQ_NAMES.extension.shortName()).getDefaultType(),
Collections.<ValueParameterDescriptor, ConstantValue<?>>emptyMap(), SourceElement.NO_SOURCE); Collections.<ValueParameterDescriptor, ConstantValue<?>>emptyMap(), SourceElement.NO_SOURCE);
} }
@@ -1,5 +1,5 @@
package somePackage package somePackage
class ExcludedClass class ExcludedClass
// Such strange name here needed to make completion prefix not intersecting with kotlin.Extension
class ExtraClass class ExctraClass
@@ -1,4 +1,4 @@
val x = Ex<caret> val x = Exc<caret>
// ABSENT: ExcludedClass // ABSENT: ExcludedClass
// EXIST: ExtraClass // EXIST: ExctraClass
@@ -1,4 +1,4 @@
val x = Ex<caret> val x = Exc<caret>
// ABSENT: ExcludedClass // ABSENT: ExcludedClass
// EXIST: ExtraClass // EXIST: ExctraClass
@@ -0,0 +1,6 @@
package somePackage;
// Such strange name here needed to make completion prefix not intersecting with kotlin.Extension
public class ExctraClass {
}
@@ -1,5 +0,0 @@
package somePackage;
public class ExtraClass {
}
@@ -6,7 +6,7 @@ fun (() -> Unit)?.helloFun1() {
fun Function0<Unit>.helloFun2() { fun Function0<Unit>.helloFun2() {
} }
fun @extension Function1<String, Unit>.helloFun3() { fun @Extension Function1<String, Unit>.helloFun3() {
} }
fun Function1<String, Unit>.helloFun4() { fun Function1<String, Unit>.helloFun4() {
@@ -6,10 +6,10 @@ fun (String.() -> Unit)?.helloFun1() {
fun Function0<Unit>.helloFun2() { fun Function0<Unit>.helloFun2() {
} }
fun @extension Function1<String, Unit>.helloFun3() { fun @Extension Function1<String, Unit>.helloFun3() {
} }
fun @extension Function1<Int, Unit>.helloFun4() { fun @Extension Function1<Int, Unit>.helloFun4() {
} }
fun Function1<String, Unit>.helloFun5() { fun Function1<String, Unit>.helloFun5() {
@@ -21,9 +21,9 @@ class FunctionTypes {
public fun f2(f: Function2<Int, *, String>) { public fun f2(f: Function2<Int, *, String>) {
} }
public fun f3(f: @extension Function2<Int, Int, Unit>) { public fun f3(f: @Extension Function2<Int, Int, Unit>) {
} }
public fun f4(f: List<@extension Function1<*, *>>) { public fun f4(f: List<@Extension Function1<*, *>>) {
} }
} }
+2 -2
View File
@@ -19,7 +19,7 @@ abstract class Types {
abstract val starList: List<*> abstract val starList: List<*>
abstract val starFun: Function1<*, *> abstract val starFun: Function1<*, *>
abstract val extFun: @extension Function2<Int, Int, Unit> abstract val extFun: @Extension Function2<Int, Int, Unit>
abstract val listExtStarFun: List<@extension Function1<*, *>> abstract val listExtStarFun: List<@Extension Function1<*, *>>
abstract val funTypeWithStarAndNonStar: Function1<*, Int> abstract val funTypeWithStarAndNonStar: Function1<*, Int>
} }
+1 -1
View File
@@ -4,4 +4,4 @@ val c: <selection>() -> String</selection> = { "" }
val d: () -> kotlin.String = { "" } val d: () -> kotlin.String = { "" }
val e: () -> Unit = { } val e: () -> Unit = { }
val f: Any.() -> String = { "" } val f: Any.() -> String = { "" }
val g: @extension Function1<String, String> = { "" } val g: @Extension Function1<String, String> = { "" }
+2 -2
View File
@@ -5,6 +5,6 @@ val d: (n: Int) -> kotlin.String = { "" }
val e: (String) -> Int = { 0 } val e: (String) -> Int = { 0 }
val f: () -> Int = { 0 } val f: () -> Int = { 0 }
val g: Int.() -> String = { "" } val g: Int.() -> String = { "" }
val h: @extension Function2<Int, Int, String> = { "" } val h: @Extension Function2<Int, Int, String> = { "" }
val i: (m: Int) -> kotlin.String = { "" } val i: (m: Int) -> kotlin.String = { "" }
val j: @extension Function1<Int, String> = { "" } val j: @Extension Function1<Int, String> = { "" }
+1 -1
View File
@@ -10,4 +10,4 @@ Int.() -> String
(m: Int) -> kotlin.String (m: Int) -> kotlin.String
@extension Function1<Int, String> @Extension Function1<Int, String>
+2 -2
View File
@@ -6,6 +6,6 @@ val e: (String) -> Int = { 0 }
val f: () -> Int = { 0 } val f: () -> Int = { 0 }
val g: Any.(Int) -> String = { "" } val g: Any.(Int) -> String = { "" }
val h: Int.(Any) -> String = { "" } val h: Int.(Any) -> String = { "" }
val i: @extension Function3<Any, Any, Int, String> = { a, b -> "" } val i: @Extension Function3<Any, Any, Int, String> = { a, b -> "" }
val j: (t: Any, u: Int) -> kotlin.String = { a, b -> "" } val j: (t: Any, u: Int) -> kotlin.String = { a, b -> "" }
val k: @extension Function2<Any, Int, String> = { "" } val k: @Extension Function2<Any, Int, String> = { "" }
+1 -1
View File
@@ -10,4 +10,4 @@ Any.(Int) -> String
(t: Any, u: Int) -> kotlin.String (t: Any, u: Int) -> kotlin.String
@extension Function2<Any, Int, String> @Extension Function2<Any, Int, String>
@@ -15,13 +15,13 @@ fun test1(): String {
} }
fun test2(): String { fun test2(): String {
val a: (@extension Function2<*, *, *>).(@extension Function2<*, *, *>)->String = { "a" } val a: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = { "a" }
val b: (@extension Function2<*, *, *>).(@extension Function2<*, *, *>)->String = { val b: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = {
val aa = this as @extension Function2<Any?, Any?, Any?>; val aa = this as @Extension Function2<Any?, Any?, Any?>;
val cc = it as @extension Function2<Any?, Any?, Any?>; val cc = it as @Extension Function2<Any?, Any?, Any?>;
"${null.aa(null)} b ${null.cc(null)}" "${null.aa(null)} b ${null.cc(null)}"
} }
val c: (@extension Function2<*, *, *>).(@extension Function2<*, *, *>)->String = { "c" } val c: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = { "c" }
val f = a.b(c) // works val f = a.b(c) // works
val s = a b c //compiler crashes val s = a b c //compiler crashes
+1 -1
View File
@@ -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. 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, 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 `@Extension`).
With this we'll get rid of classes `ExtensionFunction0`, `ExtensionFunction1`, ... With this we'll get rid of classes `ExtensionFunction0`, `ExtensionFunction1`, ...
and the rest of this article will deal only with usual functions. and the rest of this article will deal only with usual functions.