Create from Usage: Suggest "Create function/secondary constructor" quick fix on argument type mismatch
#KT-11864 Fixed (cherry picked from commit 1912783)
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
// "Create function 'foo'" "true"
|
||||
fun foo(n: Int) {}
|
||||
|
||||
fun test() {
|
||||
foo("a<caret>bc")
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Create function 'foo'" "true"
|
||||
fun foo(n: Int) {}
|
||||
|
||||
fun test() {
|
||||
foo("abc")
|
||||
}
|
||||
|
||||
fun foo(n: String) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Create secondary constructor" "true"
|
||||
// ERROR: None of the following functions can be called with the arguments supplied: <br>public constructor Foo(n: Int) defined in Foo<br>public constructor Foo(n: String) defined in Foo
|
||||
class Foo(val n: Int)
|
||||
|
||||
fun test() {
|
||||
val foo = Foo("a<caret>bc")
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// "Create secondary constructor" "true"
|
||||
// ERROR: None of the following functions can be called with the arguments supplied: <br>public constructor Foo(n: Int) defined in Foo<br>public constructor Foo(n: String) defined in Foo
|
||||
class Foo(val n: Int) {
|
||||
constructor(n: String) : this(<caret>)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val foo = Foo("abc")
|
||||
}
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
// "Add non-null asserted (!!) call" "false"
|
||||
// ACTION: Change parameter 's' type of function 'other' to 'String?'
|
||||
// ACTION: Create function 'other'
|
||||
// ERROR: Type mismatch: inferred type is String? but Int was expected
|
||||
fun test() {
|
||||
val s: String? = ""
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// "Let 'B' implement interface 'A<Int>'" "false"
|
||||
// ACTION: Change parameter 'a' type of function 'let.implement.foo' to 'B'
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: Create function 'foo'
|
||||
// ERROR: Type mismatch: inferred type is B but A<Int> was expected
|
||||
package let.implement
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// "Let 'B' implement interface 'A<*>'" "false"
|
||||
// ACTION: Change parameter 'a' type of function 'let.implement.foo' to 'B'
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: Create function 'foo'
|
||||
// ERROR: Type mismatch: inferred type is B but A<*> was expected
|
||||
|
||||
package let.implement
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// "Let 'B' implement interface 'A<Int>'" "false"
|
||||
// ACTION: Change parameter 'a' type of function 'let.implement.foo' to 'B'
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: Create function 'foo'
|
||||
// ERROR: Type mismatch: inferred type is B but A<Int> was expected
|
||||
package let.implement
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// ACTION: Change parameter 'a' type of function 'let.implement.foo' to 'String'
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: To raw string literal
|
||||
// ACTION: Create function 'foo'
|
||||
// ERROR: Type mismatch: inferred type is String but A was expected
|
||||
|
||||
package let.implement
|
||||
|
||||
Reference in New Issue
Block a user