-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refine parameter adaptation logic for arrays #23591
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -483,8 +483,13 @@ object Erasure { | |
def sameClass(tp1: Type, tp2: Type) = tp1.classSymbol == tp2.classSymbol | ||
|
||
val paramAdaptationNeeded = | ||
implParamTypes.lazyZip(samParamTypes).exists((implType, samType) => | ||
!sameClass(implType, samType) && !autoAdaptedParam(implType)) | ||
implParamTypes.lazyZip(samParamTypes).exists: (implType, samType) => | ||
!sameClass(implType, samType) && !autoAdaptedParam(implType) | ||
|| (samType, implType).match { | ||
case (defn.ArrayOf(_), defn.ArrayOf(_)) => false | ||
case (defn.ArrayOf(_), _) => true // see #23179 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't there be the reverse order as well ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unable to construct such a reversed example that will be accepted by the compiler. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need something similar for the result type ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, I also fail here to construct an example that would cause a run time crash (which is of course weak evidence). |
||
case _ => false | ||
} | ||
val resultAdaptationNeeded = | ||
!sameClass(implResultType, samResultType) && !autoAdaptedResult | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
object Test { | ||
trait A { def f(a: Array[AnyRef]): Any } | ||
def g(a: A) = a.f(Array.empty[AnyRef]) | ||
|
||
def main(args: Array[String]): Unit = { | ||
g((x: Array[? >: AnyRef]) => x.headOption) | ||
} | ||
} |