Skip to content

throw error on ambiguous overload with methods and functions #18338

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

Closed
wants to merge 2 commits into from

Conversation

iusildra
Copy link
Contributor

@iusildra iusildra commented Aug 3, 2023

Fixes #18294

From what I saw, the compiler chose the method over the function in Applications#narrowByTypes. That's because in Applications#isApplicationMethodRef() only a MethodType could give a success, so the Function1 was discarded and we could never reach the "ambiguous overloads" error

Comment on lines 1505 to 1530
case expr: TermRef if expr.widenSingleton.isInstanceOf[ExprType] =>
tp.member(nme.apply).hasAltWith(d => p(TermRef(tp, nme.apply, d)))
case methRef: TermRef if methRef.widenSingleton.isInstanceOf[MethodicType] =>
p(methRef)
Copy link
Contributor Author

@iusildra iusildra Aug 7, 2023

Choose a reason for hiding this comment

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

Here. Because ExprType <: MethodicType, it would go on to p(methRef) without an apply "attached", and then fails in isApplicableMethodRef

@iusildra iusildra marked this pull request as ready for review August 9, 2023 10:07
@iusildra iusildra changed the title switched chosen overload throw error on ambiguous overload with methods and functions Aug 15, 2023
@iusildra
Copy link
Contributor Author

It don't think it's necessary to update the comment at Applications.scala:1631

@iusildra iusildra force-pushed the i18294 branch 3 times, most recently from 932bb1d to 49c56c9 Compare August 16, 2023 17:11
@som-snytt
Copy link
Contributor

The ticket is resolved as "not ambiguous".

@iusildra iusildra closed this Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ambiguously overloaded methods fail to error when assigned to a val
2 participants