Skip to content

Commit ecf2518

Browse files
committed
Fix overriding check
1 parent 6194e13 commit ecf2518

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

compiler/src/dotty/tools/dotc/cc/Setup.scala

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
117117
* The info of these symbols is made fluid.
118118
*/
119119
def isPreCC(sym: Symbol)(using Context): Boolean =
120-
// TODO: check type members as well
121120
sym.isTerm && sym.maybeOwner.isClass
122121
&& !sym.is(Module)
123122
&& !sym.owner.is(CaptureChecked)

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import config.MigrationVersion
2121
import config.Printers.refcheck
2222
import reporting.*
2323
import Constants.Constant
24+
import cc.stripCapturing
2425

2526
object RefChecks {
2627
import tpd.*
@@ -83,8 +84,10 @@ object RefChecks {
8384
* This one used to succeed only if forwarding parameters is on.
8485
* (Forwarding tends to hide problems by binding parameter names).
8586
*/
87+
8688
private def upwardsThisType(cls: Symbol)(using Context) = cls.info match {
87-
case ClassInfo(_, _, _, _, tp: Type) if (tp ne cls.typeRef) && !cls.isOneOf(FinalOrModuleClass) =>
89+
case ClassInfo(_, _, _, _, tp: Type) if (tp.stripCapturing ne cls.typeRef) && !cls.isOneOf(FinalOrModuleClass) =>
90+
// println(i"upwardsThisType($cls) = ${cls.typeRef}, ne $tp")
8891
SkolemType(cls.appliedRef).withName(nme.this_)
8992
case _ =>
9093
cls.thisType
@@ -439,7 +442,7 @@ object RefChecks {
439442
val (mtp, otp) = if compareTypes then (memberTp(self), otherTp(self)) else (NoType, NoType)
440443
OverrideError(core, self, member, other, mtp, otp)
441444

442-
def compatTypes(memberTp: Type, otherTp: Type): Boolean =
445+
def compatTypes(memberTp: Type, otherTp: Type): Boolean = // race.force(i"compatTypes $memberTp <:< $otherTp"):
443446
try
444447
isOverridingPair(member, memberTp, other, otherTp,
445448
fallBack = warnOnMigration(

tests/neg-custom-args/captures/i21868b.scala

+1-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ class Concrete4(io: IO^) extends Abstract2(io):
2929
type C = CapSet
3030
def f(file: File) = ()
3131

32-
// TODO: Should be an error
3332
class Concrete5(io1: IO^, io2: IO^) extends Abstract2(io1):
34-
// Similar to Concrete8, this type member should have overriding error.
35-
// Parent class is Abstract2 { val io = Concrete5.this.io1 }
36-
// Abstract2.this.C >: CapSet <: CapSet^{Concrete5.this.io1}
37-
// Concrete5.this.C = CapSet^{Concrete5.this.io2}
38-
// CapSet^{Concrete5.this.io2} !<:< CapSet^{Concrete5.this.io1}
39-
// Hence, Concrete5.this.C !<:< Abstract2.this.C
40-
type C = CapSet^{io2}
33+
type C = CapSet^{io2} // error
4134
def f(file: File^{io2}) = ()
4235

4336
trait Abstract3[X^]:
@@ -53,5 +46,4 @@ class Concrete7(io1: IO^, io2: IO^) extends Abstract3[CapSet^{io1}]:
5346
def f(file: File^{io2}) = ()
5447

5548
class Concrete8(io1: IO^, io2: IO^) extends Abstract3[CapSet^{io1}]:
56-
type C = CapSet^{io1}
5749
def f(file: File^{io2}) = () // error

0 commit comments

Comments
 (0)