Skip to content

Unhelpful type erasure error with multiple parameter groups #23402

Open
@threeseed

Description

@threeseed

Compiler version

3.7.0

Minimized example

class A(p1: String, p2: Int)
object A {
 def apply(p1: String, p2: Int): A = A(p1, p2)
 def apply(p1: String)(p2: Int): A = A(p1, p2)
}

Output Error/Warning message

The error message from Scastie:

Double definition:
def apply(p1: String, p2: Int): Playground.A in object A at line 5 and
def apply(p1: String)(p2: Int): Playground.A in object A at line 6
have the same type after erasure.

Consider adding a @targetName annotation to one of the conflicting definitions
for disambiguation.

Why this Error/Warning was not helpful

I don't know what I am supposed to do with this message.

It doesn't explain to me how to fix the code, what the "same type" is or what type erasure means in my specific situation.

Suggested improvement

If multiple parameter groups are being concatenated together in the compiler it would be useful to mention that as the reason why this code is not allowed. Type erasure in general shouldn't be mentioned as it seems like an implementation detail.

Metadata

Metadata

Assignees

Labels

area:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions