Skip to content

Commit a557940

Browse files
Allow overriding opaque aliases for inline traits
1 parent 102269e commit a557940

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ object RefChecks {
340340
* of class `clazz` are met.
341341
*/
342342
def checkOverride(checkSubType: (Type, Type) => Context ?=> Boolean, member: Symbol, other: Symbol): Unit =
343-
def overridesInlineTraitMember = other.owner.ownersIterator.exists(_.isInlineTrait) && member.is(Synthetic)
344343
def isInlinedFromInlineTrait = other.owner.isAllOf(InlineTrait) && member.is(Synthetic)
345344

346345
def memberTp(self: Type) =
@@ -418,7 +417,7 @@ object RefChecks {
418417

419418
def overrideTargetNameError() =
420419
val otherTargetName = i"@targetName(${other.targetName})"
421-
if !overridesInlineTraitMember then
420+
if !isInlinedFromInlineTrait then
422421
if member.hasTargetName(member.name) then
423422
overrideError(i"misses a target name annotation $otherTargetName")
424423
else if other.hasTargetName(other.name) then
@@ -463,13 +462,13 @@ object RefChecks {
463462
// direct overrides were already checked on completion (see Checking.chckWellFormed)
464463
// the test here catches indirect overriddes between two inherited base types.
465464
overrideError("cannot be used here - class definitions cannot be overridden")
466-
else if (other.isOpaqueAlias)
465+
else if (other.isOpaqueAlias && !isInlinedFromInlineTrait)
467466
// direct overrides were already checked on completion (see Checking.chckWellFormed)
468467
// the test here catches indirect overriddes between two inherited base types.
469468
overrideError("cannot be used here - opaque type aliases cannot be overridden")
470469
else if (!other.is(Deferred) && member.isClass)
471470
overrideError("cannot be used here - classes can only override abstract types")
472-
else if (other.isEffectivelyFinal && !overridesInlineTraitMember) then // (1.2)
471+
else if (other.isEffectivelyFinal && !isInlinedFromInlineTrait) then // (1.2)
473472
overrideError(i"cannot override final member ${other.showLocated}")
474473
else if (member.is(ExtensionMethod) && !other.is(ExtensionMethod)) // (1.3)
475474
overrideError("is an extension method, cannot override a normal method")

0 commit comments

Comments
 (0)