Skip to content

fix #11583: skip typarams of right assoc ext meth #11584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -914,14 +914,22 @@ object desugar {
def badRightAssoc(problem: String) =
report.error(i"right-associative extension method $problem", mdef.srcPos)
ext.paramss ++ mdef.paramss
params1 match
def noVParam = badRightAssoc("must start with a single parameter")
def checkVparam(params: ParamClause) = params match
case ValDefs(vparam :: Nil) =>
if !vparam.mods.is(Given) then
val (leadingUsing, otherExtParamss) = ext.paramss.span(isUsingOrTypeParamClause)
leadingUsing ::: params1 :: otherExtParamss ::: paramss1
else badRightAssoc("cannot start with using clause")
case _ =>
badRightAssoc("must start with a single parameter")
noVParam
params1 match
case TypeDefs(_) => paramss1 match
case params2 :: _ => checkVparam(params2)
case _ => noVParam
case _ =>
checkVparam(params1)

case _ =>
ext.paramss ++ mdef.paramss
).withMods(mdef.mods | ExtensionMethod)
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/i11583.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extension (s: String)
def :*:[T <: Tuple](that: T) : String *: T = ???