Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ClassId name in prettifiedName if canonical name is null #484

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,13 @@ open class ClassId(
* For anonymous classes this includes the containing class and numeric indices of the anonymous class
*/
val prettifiedName: String
get() = canonicalName
.substringAfterLast(".")
.replace(Regex("[^a-zA-Z0-9]"), "")
.let { if (this.isArray) it + "Array" else it }
get() {
val className = jClass.canonicalName ?: name // Explicit jClass reference to get null instead of exception
return className
.substringAfterLast(".")
.replace(Regex("[^a-zA-Z0-9]"), "")
.let { if (this.isArray) it + "Array" else it }
}

open val packageName: String get() = jClass.`package`?.name ?: "" // empty package for primitives

Expand Down