Skip to content

Commit 3b1f9d1

Browse files
committed
Expect to rename types in Kotlin too
1 parent f37ee62 commit 3b1f9d1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

rewrite-java/src/main/java/org/openrewrite/java/ChangeType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public J.VariableDeclarations.NamedVariable visitVariable(J.VariableDeclarations
394394
if (v != variable) {
395395
if (v.getSimpleName().equals(decapitalize(originalType.getClassName()))) {
396396
if (targetType instanceof JavaType.FullyQualified) {
397-
if (v.getVariableType() != null && TypeUtils.isOfType(targetType, v.getVariableType().getType())) {
397+
if (v.getVariableType() != null && TypeUtils.isAssignableTo(targetType, v.getVariableType().getType())) {
398398
String newName = VariableNameUtils.generateVariableName(
399399
decapitalize(((JavaType.FullyQualified) targetType).getClassName()),
400400
updateCursor(v),

rewrite-kotlin/src/test/java/org/openrewrite/kotlin/ChangeTypeTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fun test(original: Original<String>) { }
195195
196196
import x.y.Target
197197
198-
fun test(original: Target<String>) { }
198+
fun test(target: Target<String>) { }
199199
"""
200200
)
201201
);
@@ -231,7 +231,7 @@ fun test(original: MyAlias<String>) { }
231231
232232
import x.y.Target as MyAlias
233233
234-
fun test(original: MyAlias<String>) { }
234+
fun test(target: MyAlias<String>) { }
235235
"""
236236
)
237237
);
@@ -263,7 +263,7 @@ fun test(original: a.b.Original<String>) { }
263263
264264
import x.y.Target
265265
266-
fun test(original: Target<String>) { }
266+
fun test(target: Target<String>) { }
267267
"""
268268
)
269269
);

0 commit comments

Comments
 (0)