[NI] Add required FactoryPattern annotation for factory pattern resolve

#KT-11265
This commit is contained in:
Dmitriy Novozhilov
2020-04-22 14:34:42 +03:00
parent 865ddac07a
commit 8c524769b1
13 changed files with 182 additions and 7 deletions
@@ -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 = ""
@@ -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 = ""
@@ -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
}
}
@@ -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 = ""
@@ -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 = ""
@@ -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
}
}
@@ -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)
}
@@ -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<!>)
}
@@ -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