Skip to content

Fix passing Seq or Array as a repeated argument when its type is union type #10014

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

Merged
merged 3 commits into from
Oct 16, 2020

Conversation

noti0na1
Copy link
Member

In the following example, the type of s is Seq[String] | Null, which is equivalent to Seq[String]. Hence, we should be allowed to pass it as a repeated argument.

import java.nio.file.Paths
def f = {
  val s: Seq[String] | Null = null
  Paths.get("", s: _*)
}

Without this fix, we will get a Type Mismatch Error:

Found:    Seq[String]
Required: String*

@noti0na1 noti0na1 requested a review from smarter October 15, 2020 21:58
@noti0na1
Copy link
Member Author

@smarter I add a special case to elemTpe and derivesFrom to handle T | Null or T | Nothing. I also rename the isBottomType to isNothingType in Types.

@noti0na1 noti0na1 merged commit e56ecae into scala:master Oct 16, 2020
griggt added a commit to griggt/dotty that referenced this pull request Oct 22, 2020
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

3 participants