@@ -2118,8 +2118,8 @@ trait Applications extends Compatibility {
2118
2118
* Each trial applies the `resolve` parameter.
2119
2119
*/
2120
2120
def resolveOverloaded
2121
- (resolve : (List [TermRef ], Type , SrcPos ) => Context ?=> List [TermRef ] = resolveOverloaded1)
2122
- (alts : List [TermRef ], pt : Type , srcPos : SrcPos )(using Context ): List [TermRef ] =
2121
+ (resolve : (List [TermRef ], Type ) => Context ?=> List [TermRef ] = resolveOverloaded1)
2122
+ (alts : List [TermRef ], pt : Type , srcPos : SrcPos = NoSourcePosition )(using Context ): List [TermRef ] =
2123
2123
record(" resolveOverloaded" )
2124
2124
2125
2125
/** Is `alt` a method or polytype whose result type after the first value parameter
@@ -2172,12 +2172,12 @@ trait Applications extends Compatibility {
2172
2172
val alts0 = alts.filterConserve(_.widen.stripPoly.isImplicitMethod)
2173
2173
if alts0 ne alts then return resolve1(alts0)
2174
2174
else if alts.exists(_.widen.stripPoly.isContextualMethod) then
2175
- return resolveMapped(alt => stripImplicit(alt.widen), resolve)(alts, pt, srcPos )
2175
+ return resolveMapped(alt => stripImplicit(alt.widen), resolve)(alts, pt)
2176
2176
case _ =>
2177
2177
2178
- var found = withoutMode(Mode .ImplicitsEnabled )(resolve(alts, pt, srcPos ))
2178
+ var found = withoutMode(Mode .ImplicitsEnabled )(resolve(alts, pt))
2179
2179
if found.isEmpty && ctx.mode.is(Mode .ImplicitsEnabled ) then
2180
- found = resolve(alts, pt, srcPos )
2180
+ found = resolve(alts, pt)
2181
2181
found match
2182
2182
case alt :: Nil => adaptByResult(alt, alts) :: Nil
2183
2183
case _ => found
@@ -2224,43 +2224,10 @@ trait Applications extends Compatibility {
2224
2224
* It might be called twice from the public `resolveOverloaded` method, once with
2225
2225
* implicits and SAM conversions enabled, and once without.
2226
2226
*/
2227
- private def resolveOverloaded1 (alts : List [TermRef ], pt : Type , srcPos : SrcPos )(using Context ): List [TermRef ] =
2227
+ private def resolveOverloaded1 (alts : List [TermRef ], pt : Type )(using Context ): List [TermRef ] =
2228
2228
trace(i " resolve over $alts%, %, pt = $pt" , typr, show = true ):
2229
2229
record(s " resolveOverloaded1 " , alts.length)
2230
2230
2231
- val sv = Feature .sourceVersion
2232
- val isOldPriorityVersion : Boolean = sv.isAtMost(SourceVersion .`3.7`)
2233
- val isWarnPriorityChangeVersion = sv == SourceVersion .`3.7` || sv == SourceVersion .`3.8-migration`
2234
-
2235
- def warnOnPriorityChange (oldCands : List [TermRef ], newCands : List [TermRef ])(f : List [TermRef ] => List [TermRef ]): List [TermRef ] =
2236
- lazy val oldRes = f(oldCands)
2237
- val newRes = f(newCands)
2238
-
2239
- def doWarn (oldChoice : String , newChoice : String ): Unit =
2240
- val (change, whichChoice) =
2241
- if isOldPriorityVersion
2242
- then (" will change" , " Current choice " )
2243
- else (" has changed" , " Previous choice" )
2244
-
2245
- val msg = // using oldCands to list the alternatives as they should be a superset of newCands
2246
- em """ Overloading resolution for ${err.expectedTypeStr(pt)} between alternatives
2247
- | ${oldCands map (_.info)}%\n %
2248
- | $change.
2249
- | $whichChoice : $oldChoice
2250
- |New choice from Scala 3.7: $newChoice"""
2251
-
2252
- report.warning(msg, srcPos)
2253
- end doWarn
2254
-
2255
- if isWarnPriorityChangeVersion then (oldRes, newRes) match
2256
- case (oldAlt :: Nil , newAlt :: Nil ) if oldAlt != newAlt => doWarn(oldAlt.info.show, newAlt.info.show)
2257
- case (oldAlt :: Nil , Nil ) => doWarn(oldAlt.info.show, " none" )
2258
- case (Nil , newAlt :: Nil ) => doWarn(" none" , newAlt.info.show)
2259
- case _ => // neither scheme has determined an alternative
2260
-
2261
- if isOldPriorityVersion then oldRes else newRes
2262
- end warnOnPriorityChange
2263
-
2264
2231
def isDetermined (alts : List [TermRef ]) = alts.isEmpty || alts.tail.isEmpty
2265
2232
2266
2233
/** The shape of given tree as a type; cannot handle named arguments. */
@@ -2290,7 +2257,7 @@ trait Applications extends Compatibility {
2290
2257
alts.filterConserve(isApplicableMethodRef(_, argTypes, resultType, ArgMatch .CompatibleCAP ))
2291
2258
2292
2259
def narrowByNextParamClause
2293
- (resolve : (List [TermRef ], Type , SrcPos ) => Context ?=> List [TermRef ])
2260
+ (resolve : (List [TermRef ], Type ) => Context ?=> List [TermRef ])
2294
2261
(alts : List [TermRef ], args : List [Tree ], resultType : FunOrPolyProto ): List [TermRef ] =
2295
2262
2296
2263
/** The type of alternative `alt` after instantiating its first parameter
@@ -2316,10 +2283,10 @@ trait Applications extends Compatibility {
2316
2283
resultType match
2317
2284
case PolyProto (targs, resType) =>
2318
2285
// try to narrow further with snd argument list and following type params
2319
- resolveMapped(skipParamClause(targs.tpes), resolve)(alts, resType, srcPos )
2286
+ resolveMapped(skipParamClause(targs.tpes), resolve)(alts, resType)
2320
2287
case resType =>
2321
2288
// try to narrow further with snd argument list
2322
- resolveMapped(skipParamClause(Nil ), resolve)(alts, resType, srcPos )
2289
+ resolveMapped(skipParamClause(Nil ), resolve)(alts, resType)
2323
2290
end narrowByNextParamClause
2324
2291
2325
2292
/** Normalization steps before checking arguments:
@@ -2381,7 +2348,7 @@ trait Applications extends Compatibility {
2381
2348
// Note it is important not to capture the outer ctx, for when it is passed to resolveMapped
2382
2349
// (through narrowByNextParamClause) which retracts the Mode.SynthesizeExtMethodReceiver from the ctx
2383
2350
// before continuing to `resolveCandidates`.
2384
- def resolveCandidates (alts : List [TermRef ], pt : Type , srcPos : SrcPos )(using Context ): List [TermRef ] = pt match
2351
+ def resolveCandidates (alts : List [TermRef ], pt : Type )(using Context ): List [TermRef ] = pt match
2385
2352
case pt @ FunProto (args, resultType) =>
2386
2353
val numArgs = args.length
2387
2354
def sizeFits (alt : TermRef ): Boolean = alt.widen.stripPoly match {
@@ -2450,7 +2417,7 @@ trait Applications extends Compatibility {
2450
2417
TypeOps .boundsViolations(targs1, tp.paramInfos, _.substParams(tp, _), NoType ).isEmpty
2451
2418
val alts2 = alts1.filter(withinBounds)
2452
2419
if isDetermined(alts2) then alts2
2453
- else resolveMapped(_.widen.appliedTo(targs1.tpes), resolveCandidates)(alts1, pt1, srcPos )
2420
+ else resolveMapped(_.widen.appliedTo(targs1.tpes), resolveCandidates)(alts1, pt1)
2454
2421
2455
2422
case pt =>
2456
2423
val compat = alts.filterConserve(normalizedCompatible(_, pt, keepConstraint = false ))
@@ -2481,7 +2448,7 @@ trait Applications extends Compatibility {
2481
2448
case _ => false
2482
2449
2483
2450
// Like resolveCandidates, we should not capture the outer ctx parameter.
2484
- def resolveOverloaded2 (candidates : List [TermRef ], pt : Type , srcPos : SrcPos )(using Context ): List [TermRef ] =
2451
+ def resolveOverloaded2 (candidates : List [TermRef ], pt : Type )(using Context ): List [TermRef ] =
2485
2452
if pt.unusableForInference then
2486
2453
// `pt` might have become erroneous by typing arguments of FunProtos.
2487
2454
// If `pt` is erroneous, don't try to go further; report the error in `pt` instead.
@@ -2493,27 +2460,26 @@ trait Applications extends Compatibility {
2493
2460
val deepPt = pt.deepenProto
2494
2461
deepPt match
2495
2462
case pt @ FunProto (_, resType : FunOrPolyProto ) =>
2496
- warnOnPriorityChange(candidates, found):
2497
- narrowByNextParamClause(resolveOverloaded1)(_, pt.typedArgs(), resType)
2463
+ narrowByNextParamClause(resolveOverloaded1)(found, pt.typedArgs(), resType)
2498
2464
case _ =>
2499
2465
// prefer alternatives that need no eta expansion
2500
2466
val noCurried = alts.filterConserve(! resultIsMethod(_))
2501
2467
val noCurriedCount = noCurried.length
2502
2468
if noCurriedCount == 1 then
2503
2469
noCurried
2504
2470
else if noCurriedCount > 1 && noCurriedCount < alts.length then
2505
- resolveOverloaded1(noCurried, pt, srcPos )
2471
+ resolveOverloaded1(noCurried, pt)
2506
2472
else
2507
2473
// prefer alternatves that match without default parameters
2508
2474
val noDefaults = alts.filterConserve(! _.symbol.hasDefaultParams)
2509
2475
val noDefaultsCount = noDefaults.length
2510
2476
if noDefaultsCount == 1 then
2511
2477
noDefaults
2512
2478
else if noDefaultsCount > 1 && noDefaultsCount < alts.length then
2513
- resolveOverloaded1(noDefaults, pt, srcPos )
2479
+ resolveOverloaded1(noDefaults, pt)
2514
2480
else if deepPt ne pt then
2515
2481
// try again with a deeper known expected type
2516
- resolveOverloaded1(alts, deepPt, srcPos )
2482
+ resolveOverloaded1(alts, deepPt)
2517
2483
else
2518
2484
candidates
2519
2485
end resolveOverloaded2
@@ -2523,9 +2489,9 @@ trait Applications extends Compatibility {
2523
2489
// but restarting from the 1st argument list.
2524
2490
// In both cases, considering subsequent argument lists only narrows the set of alternatives
2525
2491
// (i.e. we do retry from the complete list of alternative mapped onto there next param clause).
2526
- val candidates = resolveCandidates(alts, pt, srcPos )
2492
+ val candidates = resolveCandidates(alts, pt)
2527
2493
record(" resolveOverloaded.narrowedApplicable" , candidates.length)
2528
- resolveOverloaded2(candidates, pt, srcPos )
2494
+ resolveOverloaded2(candidates, pt)
2529
2495
end resolveOverloaded1
2530
2496
2531
2497
/** Is `formal` a product type which is elementwise compatible with `params`? */
@@ -2557,8 +2523,8 @@ trait Applications extends Compatibility {
2557
2523
* and the expected type is `pt`. Map the results back to the original alternatives.
2558
2524
*/
2559
2525
def resolveMapped
2560
- (f : TermRef => Type , resolve : (List [TermRef ], Type , SrcPos ) => Context ?=> List [TermRef ])
2561
- (alts : List [TermRef ], pt : Type , srcPos : SrcPos )(using Context ): List [TermRef ] =
2526
+ (f : TermRef => Type , resolve : (List [TermRef ], Type ) => Context ?=> List [TermRef ])
2527
+ (alts : List [TermRef ], pt : Type )(using Context ): List [TermRef ] =
2562
2528
val reverseMapping = alts.flatMap { alt =>
2563
2529
val t = f(alt)
2564
2530
if t.exists && alt.symbol.exists then
@@ -2581,7 +2547,7 @@ trait Applications extends Compatibility {
2581
2547
}
2582
2548
val mapped = reverseMapping.map(_._1)
2583
2549
overload.println(i " resolve mapped: ${mapped.map(_.widen)}%, % with $pt" )
2584
- resolveOverloaded(resolve)(mapped, pt, srcPos )(using ctx.retractMode(Mode .SynthesizeExtMethodReceiver ))
2550
+ resolveOverloaded(resolve)(mapped, pt)(using ctx.retractMode(Mode .SynthesizeExtMethodReceiver ))
2585
2551
.map(reverseMapping.toMap)
2586
2552
end resolveMapped
2587
2553
0 commit comments