Skip to content

Commit e160140

Browse files
committed
Allow optional : in extension
There's will probably be a tendency to put a `:` in a collective extension by analogy to given and object, trait etc. We don't need to be picky about this.
1 parent b179a8e commit e160140

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,6 +3646,8 @@ object Parsers {
36463646
val tparams = typeParamClauseOpt(ParamOwner.Def)
36473647
val extParams = paramClause(0, prefix = true)
36483648
val givenParamss = paramClauses(givenOnly = true)
3649+
in.observeColonEOL()
3650+
if (in.token == COLONEOL) in.nextToken()
36493651
val methods =
36503652
if isDefIntro(modifierTokens) then
36513653
extMethod() :: Nil

tests/neg/i6900.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Test2 {
22

33
// Works with extension method
4-
extension [A](a: A)
4+
extension [A](a: A):
55
def foo[C]: C => A = _ => a // error: extension method cannot have type parameters
66

77
1.foo.foo

tests/pos/i6900.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object Test1 {
2121
object Test2 {
2222

2323
// Works with extension method
24-
extension [A, C](a: A)
24+
extension [A, C](a: A):
2525
def foo: C => A = _ => a
2626

2727
1.foo.foo

0 commit comments

Comments
 (0)