Skip to content

Commit 2e700aa

Browse files
committed
Treat new style given syntax without a rhs or template as concrete
To make an abstract given with new style syntax, one needs to write `= deferred`.
1 parent 223fe32 commit 2e700aa

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4108,7 +4108,7 @@ object Parsers {
41084108
ValDef(name, parents.head, subExpr())
41094109
else
41104110
DefDef(name, adjustDefParams(joinParams(tparams, vparamss)), parents.head, subExpr())
4111-
else if (isStatSep || isStatSeqEnd) && parentsIsType then
4111+
else if (isStatSep || isStatSeqEnd) && parentsIsType && !newSyntaxAllowed then
41124112
if name.isEmpty then
41134113
syntaxError(em"anonymous given cannot be abstract")
41144114
DefDef(name, adjustDefParams(joinParams(tparams, vparamss)), parents.head, EmptyTree)

tests/neg/deferred-givens.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -YXtypeclass -source future
1+
//> using options -language:experimental.modularity -source future
22
class Ctx
33
class Ctx2
44

tests/pos/hylolib/Integers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ given Int is Comparable:
4343

4444
def lt(other: Int): Boolean = self < other
4545

46-
given Int is StringConvertible {}
46+
given Int is StringConvertible

0 commit comments

Comments
 (0)