[NI] Add required FactoryPattern annotation for factory pattern resolve
#KT-11265
This commit is contained in:
+12
@@ -2,6 +2,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
// FILE: FactoryPattern.kt
|
||||
|
||||
package annotations
|
||||
|
||||
annotation class FactoryPattern
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import annotations.FactoryPattern
|
||||
|
||||
@FactoryPattern
|
||||
fun create(f: (Int) -> Int): Int = 1
|
||||
fun create(f: (Int) -> String): String = ""
|
||||
|
||||
@@ -22,6 +33,7 @@ fun test_3() {
|
||||
val x = <!AMBIGUITY!>create<!> { 1.0 }
|
||||
}
|
||||
|
||||
@FactoryPattern
|
||||
fun <K> create(x: K, f: (K) -> Int): Int = 1
|
||||
fun <T> create(x: T, f: (T) -> String): String = ""
|
||||
|
||||
|
||||
Vendored
+12
@@ -2,6 +2,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
// FILE: FactoryPattern.kt
|
||||
|
||||
package annotations
|
||||
|
||||
annotation class FactoryPattern
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import annotations.FactoryPattern
|
||||
|
||||
@FactoryPattern
|
||||
fun create(f: (Int) -> Int): Int = 1
|
||||
fun create(f: (Int) -> String): String = ""
|
||||
|
||||
@@ -22,6 +33,7 @@ fun test_3() {
|
||||
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!> { 1.0 }
|
||||
}
|
||||
|
||||
@FactoryPattern
|
||||
fun <K> create(x: K, f: (K) -> Int): Int = 1
|
||||
fun <T> create(x: T, f: (T) -> String): String = ""
|
||||
|
||||
|
||||
compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.txt
Vendored
+12
-2
@@ -1,8 +1,8 @@
|
||||
package
|
||||
|
||||
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.Int): kotlin.Int
|
||||
@annotations.FactoryPattern public fun create(/*0*/ f: (kotlin.Int) -> kotlin.Int): kotlin.Int
|
||||
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.String): kotlin.String
|
||||
public fun </*0*/ K> create(/*0*/ x: K, /*1*/ f: (K) -> kotlin.Int): kotlin.Int
|
||||
@annotations.FactoryPattern public fun </*0*/ K> create(/*0*/ x: K, /*1*/ f: (K) -> kotlin.Int): kotlin.Int
|
||||
public fun </*0*/ T> create(/*0*/ x: T, /*1*/ f: (T) -> kotlin.String): kotlin.String
|
||||
public fun takeInt(/*0*/ s: kotlin.Int): kotlin.Unit
|
||||
public fun takeString(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
@@ -11,3 +11,13 @@ public fun test_2(): kotlin.Unit
|
||||
public fun test_3(): kotlin.Unit
|
||||
public fun test_4(): kotlin.Unit
|
||||
public fun test_5(): kotlin.Unit
|
||||
|
||||
package annotations {
|
||||
|
||||
public final annotation class FactoryPattern : kotlin.Annotation {
|
||||
public constructor FactoryPattern()
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -2,6 +2,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
// FILE: FactoryPattern.kt
|
||||
|
||||
package annotations
|
||||
|
||||
annotation class FactoryPattern
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import annotations.FactoryPattern
|
||||
|
||||
@FactoryPattern
|
||||
fun create(f: (Int) -> Int): Int = 1
|
||||
fun create(f: (Int) -> String): String = ""
|
||||
|
||||
@@ -22,6 +33,7 @@ fun test_3() {
|
||||
val x = <!AMBIGUITY!>create<!> { 1.0 }
|
||||
}
|
||||
|
||||
@FactoryPattern
|
||||
fun <K> create(x: K, f: (K) -> Int): Int = 1
|
||||
fun <T> create(x: T, f: (T) -> String): String = ""
|
||||
|
||||
|
||||
Vendored
+12
@@ -2,6 +2,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
// FILE: FactoryPattern.kt
|
||||
|
||||
package annotations
|
||||
|
||||
annotation class FactoryPattern
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import annotations.FactoryPattern
|
||||
|
||||
@FactoryPattern
|
||||
fun create(f: (Int) -> Int): Int = 1
|
||||
fun create(f: (Int) -> String): String = ""
|
||||
|
||||
@@ -22,6 +33,7 @@ fun test_3() {
|
||||
val x = <!NONE_APPLICABLE!>create<!> { 1.0 }
|
||||
}
|
||||
|
||||
@FactoryPattern
|
||||
fun <K> create(x: K, f: (K) -> Int): Int = 1
|
||||
fun <T> create(x: T, f: (T) -> String): String = ""
|
||||
|
||||
|
||||
Vendored
+12
-2
@@ -1,8 +1,8 @@
|
||||
package
|
||||
|
||||
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.Int): kotlin.Int
|
||||
@annotations.FactoryPattern public fun create(/*0*/ f: (kotlin.Int) -> kotlin.Int): kotlin.Int
|
||||
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.String): kotlin.String
|
||||
public fun </*0*/ K> create(/*0*/ x: K, /*1*/ f: (K) -> kotlin.Int): kotlin.Int
|
||||
@annotations.FactoryPattern public fun </*0*/ K> create(/*0*/ x: K, /*1*/ f: (K) -> kotlin.Int): kotlin.Int
|
||||
public fun </*0*/ T> create(/*0*/ x: T, /*1*/ f: (T) -> kotlin.String): kotlin.String
|
||||
public fun takeInt(/*0*/ s: kotlin.Int): kotlin.Unit
|
||||
public fun takeString(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
@@ -11,3 +11,13 @@ public fun test_2(): kotlin.Unit
|
||||
public fun test_3(): kotlin.Unit
|
||||
public fun test_4(): kotlin.Unit
|
||||
public fun test_5(): kotlin.Unit
|
||||
|
||||
package annotations {
|
||||
|
||||
public final annotation class FactoryPattern : kotlin.Annotation {
|
||||
public constructor FactoryPattern()
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// !LANGUAGE: +NewInference +FactoryPatternResolution
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
fun create(f: (Int) -> Int): Int = 1
|
||||
fun create(f: (Int) -> String): String = ""
|
||||
|
||||
fun takeString(s: String) {}
|
||||
fun takeInt(s: Int) {}
|
||||
|
||||
fun test_1() {
|
||||
val x = <!AMBIGUITY!>create<!> { "" }
|
||||
takeString(x)
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
val x = <!AMBIGUITY!>create<!> { 1 }
|
||||
takeInt(x)
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
val x = <!AMBIGUITY!>create<!> { 1.0 }
|
||||
}
|
||||
|
||||
fun <K> create(x: K, f: (K) -> Int): Int = 1
|
||||
fun <T> create(x: T, f: (T) -> String): String = ""
|
||||
|
||||
fun test_4() {
|
||||
val x = <!AMBIGUITY!>create<!>("") { "" }
|
||||
takeString(x)
|
||||
}
|
||||
|
||||
fun test_5() {
|
||||
val x = <!AMBIGUITY!>create<!>("") { 1 }
|
||||
takeInt(x)
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// !LANGUAGE: +NewInference +FactoryPatternResolution
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
fun create(f: (Int) -> Int): Int = 1
|
||||
fun create(f: (Int) -> String): String = ""
|
||||
|
||||
fun takeString(s: String) {}
|
||||
fun takeInt(s: Int) {}
|
||||
|
||||
fun test_1() {
|
||||
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!> { "" }
|
||||
takeString(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>)
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!> { 1 }
|
||||
takeInt(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>)
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!> { 1.0 }
|
||||
}
|
||||
|
||||
fun <K> create(x: K, f: (K) -> Int): Int = 1
|
||||
fun <T> create(x: T, f: (T) -> String): String = ""
|
||||
|
||||
fun test_4() {
|
||||
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!>("") { "" }
|
||||
takeString(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>)
|
||||
}
|
||||
|
||||
fun test_5() {
|
||||
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!>("") { 1 }
|
||||
takeInt(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>)
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.Int): kotlin.Int
|
||||
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.String): kotlin.String
|
||||
public fun </*0*/ K> create(/*0*/ x: K, /*1*/ f: (K) -> kotlin.Int): kotlin.Int
|
||||
public fun </*0*/ T> create(/*0*/ x: T, /*1*/ f: (T) -> kotlin.String): kotlin.String
|
||||
public fun takeInt(/*0*/ s: kotlin.Int): kotlin.Unit
|
||||
public fun takeString(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
public fun test_1(): kotlin.Unit
|
||||
public fun test_2(): kotlin.Unit
|
||||
public fun test_3(): kotlin.Unit
|
||||
public fun test_4(): kotlin.Unit
|
||||
public fun test_5(): kotlin.Unit
|
||||
Reference in New Issue
Block a user