Skip to content

Commit

Permalink
Fix a type mapping bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kunli2 committed Nov 10, 2023
1 parent ce614e3 commit 314267f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/kotlin/org/openrewrite/kotlin/KotlinTypeMapping.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ class KotlinTypeMapping(
return Unknown.getInstance()
}
val signature = signatureBuilder.signature(type, parent)
val existing = typeCache.get<JavaType>(signature)
if (existing != null) {
return existing
if (signature.isNotEmpty()) {
val existing = typeCache.get<JavaType>(signature)
if (existing != null) {
return existing
}
}

return type(type, parent, signature)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,21 @@ interface B
)
);
}

@Issue("https://github.com/openrewrite/rewrite-kotlin/issues/373")
@Test
void anonymousObject2() {
rewriteRun(
kotlin(
"""
open class Object<T>
class Test(name: String, any: Any)
fun <T> foo(name: String) =
Test(name, object : Object<T>() {
})
"""
)
);
}
}

1 comment on commit 314267f

@kunli2
Copy link
Contributor Author

@kunli2 kunli2 commented on 314267f Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed #373

Please sign in to comment.