Skip to content

Commit f955f8b

Browse files
authored
Merge pull request #14371 from KacperFKorban/fix-i14343
Correctly handle context functions in scaladoc
2 parents 3c82006 + 60aba09 commit f955f8b

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package tests.contextfunctions
2+
3+
val x: Int ?=> Float
4+
= 5.0f

scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,19 @@ trait TypesSupport:
182182
++ plain(" ").l
183183
++ inner(typeList.last)
184184
else if t.isFunctionType then
185+
val arrow = if t.isContextFunctionType then " ?=> " else " => "
185186
typeList match
186187
case Nil =>
187188
Nil
188189
case Seq(rtpe) =>
189-
plain("()").l ++ keyword(" => ").l ++ inner(rtpe)
190+
plain("()").l ++ keyword(arrow).l ++ inner(rtpe)
190191
case Seq(arg, rtpe) =>
191192
val partOfSignature = arg match
192193
case byName: ByNameType => plain("(").l ++ inner(byName) ++ plain(")").l
193194
case _ => inner(arg)
194-
partOfSignature ++ keyword(" => ").l ++ inner(rtpe)
195+
partOfSignature ++ keyword(arrow).l ++ inner(rtpe)
195196
case args =>
196-
plain("(").l ++ commas(args.init.map(inner)) ++ plain(")").l ++ keyword(" => ").l ++ inner(args.last)
197+
plain("(").l ++ commas(args.init.map(inner)) ++ plain(")").l ++ keyword(arrow).l ++ inner(args.last)
197198
else if t.isTupleN then
198199
typeList match
199200
case Nil =>

scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,5 @@ class ContextBounds extends SignatureTest("contextBounds", SignatureTest.all)
9090
class FBoundedTypeParameters extends SignatureTest("fboundedTypeParameters", SignatureTest.all)
9191

9292
class Exports extends SignatureTest("exports2", SignatureTest.all, sourceFiles = List("exports1", "exports2"))
93+
94+
class ContextFunctions extends SignatureTest("contextfunctions", SignatureTest.all)

0 commit comments

Comments
 (0)