Skip to content

Commit 0be4099

Browse files
authored
Merge pull request #11584 from dotty-staging/fix-11583
fix #11583: skip typarams of right assoc ext meth
2 parents 4ed026c + 39fc4f3 commit 0be4099

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,14 +914,22 @@ object desugar {
914914
def badRightAssoc(problem: String) =
915915
report.error(i"right-associative extension method $problem", mdef.srcPos)
916916
ext.paramss ++ mdef.paramss
917-
params1 match
917+
def noVParam = badRightAssoc("must start with a single parameter")
918+
def checkVparam(params: ParamClause) = params match
918919
case ValDefs(vparam :: Nil) =>
919920
if !vparam.mods.is(Given) then
920921
val (leadingUsing, otherExtParamss) = ext.paramss.span(isUsingOrTypeParamClause)
921922
leadingUsing ::: params1 :: otherExtParamss ::: paramss1
922923
else badRightAssoc("cannot start with using clause")
923924
case _ =>
924-
badRightAssoc("must start with a single parameter")
925+
noVParam
926+
params1 match
927+
case TypeDefs(_) => paramss1 match
928+
case params2 :: _ => checkVparam(params2)
929+
case _ => noVParam
930+
case _ =>
931+
checkVparam(params1)
932+
925933
case _ =>
926934
ext.paramss ++ mdef.paramss
927935
).withMods(mdef.mods | ExtensionMethod)

tests/pos/i11583.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
extension (s: String)
2+
def :*:[T <: Tuple](that: T) : String *: T = ???

0 commit comments

Comments
 (0)