Skip to content

Commit

Permalink
fix: Do not make deferred given implementations final
Browse files Browse the repository at this point in the history
It should be possible to extend a class that inherits a deferred given,
so a generated given implementation should not be final.
  • Loading branch information
KacperFKorban committed Jul 16, 2024
1 parent 12d50a2 commit 50dc7b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3038,7 +3038,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
body

/** Implement givens that were declared with a `deferred` rhs.
* The a given value matching the declared type is searched in a
* The given value matching the declared type is searched in a
* context directly enclosing the current class, in which all given
* parameters of the current class are also defined.
*/
Expand Down Expand Up @@ -3067,7 +3067,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
)(using searchCtx)

val impl = dcl.copy(cls,
flags = dcl.flags &~ (HasDefault | Deferred) | Final | Override,
flags = dcl.flags &~ (HasDefault | Deferred) | Override,
info = target,
coord = rhs.span).entered.asTerm

Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i21189.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//> using options -source:future -language:experimental.modularity

class MySortedSet[T : Ord] extends SortedSet[T]

trait Ord[T]

trait Sorted[T]:
given Ord[T] as ord = compiletime.deferred

class SortedSet[T : Ord] extends Sorted[T]

0 comments on commit 50dc7b5

Please sign in to comment.