Create from Usage: Generate secondary constructors by call expressions
This commit is contained in:
+1
@@ -2,6 +2,7 @@
|
||||
// ACTION: Create function 'Foo'
|
||||
// ACTION: Add parameter to constructor 'Foo'
|
||||
// ACTION: Split property declaration
|
||||
// ACTION: Create secondary constructor
|
||||
// ERROR: Too many arguments for public constructor Foo(a: kotlin.Int) defined in Foo
|
||||
|
||||
class Foo(a: Int)
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
// ACTION: Create function 'Foo'
|
||||
// ACTION: Remove parameter 's'
|
||||
// ACTION: Split property declaration
|
||||
// ACTION: Create secondary constructor
|
||||
// ERROR: No value passed for parameter s
|
||||
|
||||
class Foo(i: Int, s: String)
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Create secondary constructor" "true"
|
||||
|
||||
trait T
|
||||
|
||||
class A: T {
|
||||
constructor(i: Int) {
|
||||
//To change body of created constructors use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val t: T = A(1)
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Create secondary constructor" "true"
|
||||
|
||||
class A {
|
||||
constructor(i: Int) {
|
||||
//To change body of created constructors use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val a = A(1)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Create secondary constructor" "true"
|
||||
|
||||
class A {
|
||||
constructor(i: Int) {
|
||||
//To change body of created constructors use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val a = A(1)
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create secondary constructor" "true"
|
||||
|
||||
trait T
|
||||
|
||||
class A: T
|
||||
|
||||
fun test() {
|
||||
val t: T = A(<caret>1)
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Create secondary constructor" "false"
|
||||
// ACTION: Add parameter to constructor 'A'
|
||||
// ACTION: Create function 'A'
|
||||
// ACTION: Split property declaration
|
||||
// ERROR: No type arguments expected
|
||||
// ERROR: Too many arguments for public constructor A() defined in A
|
||||
|
||||
class A
|
||||
|
||||
fun test() {
|
||||
val a = A<Int>(<caret>1)
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create secondary constructor" "true"
|
||||
|
||||
class A {
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val a = A(<caret>1)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Create secondary constructor" "true"
|
||||
|
||||
class A
|
||||
|
||||
fun test() {
|
||||
val a = A(<caret>1)
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Create secondary constructor" "false"
|
||||
// ACTION: Add parameter to constructor 'A'
|
||||
// ACTION: Change 'b' type to 'A'
|
||||
// ACTION: Create function 'A'
|
||||
// ACTION: Split property declaration
|
||||
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>B</td></tr><tr><td>Found:</td><td>A</td></tr></table></html>
|
||||
// ERROR: Too many arguments for public constructor A() defined in A
|
||||
|
||||
class A
|
||||
|
||||
class B
|
||||
|
||||
fun test() {
|
||||
val b: B = A(<caret>1)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Create secondary constructor" "false"
|
||||
// ERROR: Too many arguments for public constructor G() defined in G
|
||||
// ACTION: Add parameter to constructor 'G'
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Create function 'G'
|
||||
|
||||
fun test() = G(<caret>1)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class G {
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class J {
|
||||
|
||||
public J(int i) {
|
||||
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create secondary constructor" "true"
|
||||
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
|
||||
|
||||
fun test() = J(1)
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create secondary constructor" "true"
|
||||
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
|
||||
|
||||
fun test() = J(<caret>1)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class J {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user