Kotlin / Kotlin/dataframe

Investigate `sumOf { literal }` overload ambiguity and define expected behavior

Open
#1,704 8 comments 1 reaction 1 assignee Claimed by @AndreiKingsley View on GitHub
bug research
Dominant language
Kotlin
Stars
1.1k
Forks
83
Avg merge
4d 12h
Merged PRs (30d)
30

Description

Image

```
val df = dataFrameOf("a" to columnOf(1))

df.sumOf { 123 }
df.sumOf { a }
```

Needs a cast
Image

Hard to tell if compiler is expected to resolve the call without a cast

### Problem

Using a literal in `sumOf` leads to overload ambiguity:

`df.sumOf { 123 }` — does not compile
`df.sumOf { 123 as Int }` — works
`df.sumOf { a }` — works

The issue is that `123` is inferred as an integer literal type, and the compiler cannot choose between multiple `sumOf` overloads.

### Question

Is this:
- a limitation of Kotlin type inference, or
- something that can be improved at the DataFrame API level?

### Expected

Clarify intended behavior and feasibility.

### Acceptance criteria

- Root cause identified (Kotlin limitation vs library issue)
- Decision made:
- keep current behavior, or
- introduce a workaround at API level (if feasible)
- If not fixable:
- document requirement to use explicit cast (e.g. `123 as Int`)

### Motivation

- `sumOf` is a core aggregation API
- Current behavior is non-obvious for users
- Needs clear definition before 1.0 stabilization

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.