google / google/ksp

Logging with implicit property getter doesn't include the file or line number

Open
#2,288 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Kotlin
Stars
3.5k
Forks
415
Avg merge
1d 2h
Merged PRs (30d)
53

Description

We have some code that processes properties and potentially logs an error. The property is defined like this:
```kotlin
abstract class SomeClass {
@get:SomeAnnotation
abstract val stuff: List
}
```

We log an error like this:
```kotlin
fun KSPropertyGetter.logError() {
environment.logger.error("Example error, this)
}
```

In KSP1 this would correctly print:
```
Test.kt:3: Example error
```
but in KSP2 this prints
```
Example error
```

If I use `this.parent` (which uses the property declaration) it works as expected. I assume this is because there no explicit getter.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.