@@ -360,27 +360,6 @@ object RefChecks {
360
360
361
361
// Console.println(infoString(member) + " overrides " + infoString(other) + " in " + clazz);//DEBUG
362
362
363
- // return if we already checked this combination elsewhere
364
- if (member.owner != clazz) {
365
- def deferredCheck = member.is(Deferred ) || ! other.is(Deferred )
366
- def subOther (s : Symbol ) = s derivesFrom other.owner
367
- def subMember (s : Symbol ) = s derivesFrom member.owner
368
-
369
- if (subOther(member.owner) && deferredCheck)
370
- // Console.println(infoString(member) + " shadows1 " + infoString(other) " in " + clazz);//DEBUG
371
- return
372
- val parentSymbols = clazz.info.parents.map(_.typeSymbol)
373
- def matchIn (parent : Symbol ): Boolean = considerMatching(member, other, parent.thisType)
374
- if parentSymbols.exists(p =>
375
- subOther(p) && subMember(p) && deferredCheck && matchIn(p))
376
- then
377
- // Console.println(infoString(member) + " shadows2 " + infoString(other) + " in " + clazz);//DEBUG
378
- return
379
- if parentSymbols.forall(p => subOther(p) == subMember(p) && matchIn(p)) then
380
- // Console.println(infoString(member) + " shadows " + infoString(other) + " in " + clazz);//DEBUG
381
- return
382
- }
383
-
384
363
/* Is the intersection between given two lists of overridden symbols empty? */
385
364
def intersectionIsEmpty (syms1 : Iterator [Symbol ], syms2 : Iterator [Symbol ]) = {
386
365
val set2 = syms2.toSet
@@ -508,21 +487,27 @@ object RefChecks {
508
487
* - matching names and types, but different target names
509
488
*/
510
489
def considerMatching (sym1 : Symbol , sym2 : Symbol , self : Type ): Boolean =
511
- ! (sym1.owner.is(JavaDefined , butNot = Trait ) && sym2.owner.is(JavaDefined , butNot = Trait )) && // javac already handles these checks
512
- (sym1.isType || {
513
- val sd1 = sym1.asSeenFrom(self)
514
- val sd2 = sym2.asSeenFrom(self)
515
- sd1.matchesLoosely(sd2)
490
+ if sym1.owner.is(JavaDefined , butNot = Trait )
491
+ && sym2.owner.is(JavaDefined , butNot = Trait )
492
+ then false // javac already handles these checks
493
+ else if sym1.isType then true
494
+ else
495
+ val sd1 = sym1.asSeenFrom(self)
496
+ val sd2 = sym2.asSeenFrom(self)
497
+ sd1.matchesLoosely(sd2)
516
498
&& (sym1.hasTargetName(sym2.targetName)
517
499
|| compatibleTypes(sym1, sd1.info, sym2, sd2.info))
518
- })
519
500
520
501
val opc = new OverridingPairs .Cursor (clazz):
521
502
override def matches (sym1 : Symbol , sym2 : Symbol ): Boolean =
522
503
considerMatching(sym1, sym2, self)
504
+
505
+ // We can exclude pairs safely from checking only of they also matched in
506
+ // the parent class. See neg/i12828.scala for an example where this matters.
523
507
override def canBeHandledByParent (sym1 : Symbol , sym2 : Symbol , parentType : Type ): Boolean =
524
508
considerMatching(sym1, sym2, parentType)
525
509
.showing(i " already handled ${sym1.showLocated}: ${sym1.asSeenFrom(parentType).signature}, ${sym2.showLocated}: ${sym2.asSeenFrom(parentType).signature} = $result" , refcheck)
510
+ end opc
526
511
527
512
while opc.hasNext do
528
513
checkOverride(opc.overriding, opc.overridden)
0 commit comments