Implement quckfix adding explicit upper bounds for generic when needed
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
|
||||
fun <T : Any> foo() = 1
|
||||
|
||||
fun <E> bar() = foo<E<caret>>()
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
|
||||
fun <T : Any> foo() = 1
|
||||
|
||||
fun <E : Any> bar() = foo<E>()
|
||||
@@ -0,0 +1,6 @@
|
||||
// "class org.jetbrains.kotlin.idea.quickfix.AddGenericUpperBoundFix" "false"
|
||||
// ERROR: <html>Type argument is not within its bounds.<table><tr><td>Expected:</td><td>kotlin.Any</td></tr><tr><td>Found:</td><td>E</td></tr></table></html>
|
||||
|
||||
fun <T : Any> foo() = 1
|
||||
|
||||
fun <E : Any?> bar() = foo<E<caret>>()
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
// ERROR: <html>Type parameter bound for <b>U</b> in <table><tr><td width="10%"></td><td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;"><b>fun</b> <T : kotlin.Any, U : kotlin.Any> foo</td><td style="white-space:nowrap;font-weight:bold;">(</td><td align="right" style="white-space:nowrap;font-weight:bold;">x: T,</td><td align="right" style="white-space:nowrap;font-weight:bold;">y: U</td><td style="white-space:nowrap;font-weight:bold;">)</td><td style="white-space:nowrap;font-weight:bold;">: kotlin.Int</td></tr></table> is not satisfied: inferred type <font color=red><b>F</b></font> is not a subtype of <b>kotlin.Any</b></html>
|
||||
|
||||
fun <T : Any, U: Any> foo(x: T, y: U) = 1
|
||||
|
||||
fun <E, F> bar(x: E, y: F) = <caret>foo(x, y)
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
// ERROR: <html>Type parameter bound for <b>U</b> in <table><tr><td width="10%"></td><td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;"><b>fun</b> <T : kotlin.Any, U : kotlin.Any> foo</td><td style="white-space:nowrap;font-weight:bold;">(</td><td align="right" style="white-space:nowrap;font-weight:bold;">x: T,</td><td align="right" style="white-space:nowrap;font-weight:bold;">y: U</td><td style="white-space:nowrap;font-weight:bold;">)</td><td style="white-space:nowrap;font-weight:bold;">: kotlin.Int</td></tr></table> is not satisfied: inferred type <font color=red><b>F</b></font> is not a subtype of <b>kotlin.Any</b></html>
|
||||
|
||||
fun <T : Any, U: Any> foo(x: T, y: U) = 1
|
||||
|
||||
fun <E : Any, F> bar(x: E, y: F) = <caret>foo(x, y)
|
||||
@@ -0,0 +1,3 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
|
||||
inline fun <reified /* abc */ E> bar() = E::class.java<caret>
|
||||
@@ -0,0 +1,3 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
|
||||
inline fun <reified /* abc */ E : Any> bar() = E::class.java
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Add 'E' as upper bound for F" "true"
|
||||
|
||||
fun <T, U : T> foo() = 1
|
||||
|
||||
fun <E, F> bar() = foo<E, F<caret>>()
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Add 'E' as upper bound for F" "true"
|
||||
|
||||
fun <T, U : T> foo() = 1
|
||||
|
||||
fun <E, F : E> bar() = foo<E, F<caret>>()
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
|
||||
class A<T : Any>
|
||||
fun <E> bar(x: A<E<caret>>) {}
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
|
||||
class A<T : Any>
|
||||
fun <E : Any> bar(x: A<E<caret>>) {}
|
||||
Reference in New Issue
Block a user