Skip to content

Commit

Permalink
Merge pull request #14371 from KacperFKorban/fix-i14343
Browse files Browse the repository at this point in the history
Correctly handle context functions in scaladoc
  • Loading branch information
BarkingBad authored Jan 28, 2022
2 parents 3c82006 + 60aba09 commit f955f8b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions scaladoc-testcases/src/tests/contextfunctions.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package tests.contextfunctions

val x: Int ?=> Float
= 5.0f
7 changes: 4 additions & 3 deletions scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,19 @@ trait TypesSupport:
++ plain(" ").l
++ inner(typeList.last)
else if t.isFunctionType then
val arrow = if t.isContextFunctionType then " ?=> " else " => "
typeList match
case Nil =>
Nil
case Seq(rtpe) =>
plain("()").l ++ keyword(" => ").l ++ inner(rtpe)
plain("()").l ++ keyword(arrow).l ++ inner(rtpe)
case Seq(arg, rtpe) =>
val partOfSignature = arg match
case byName: ByNameType => plain("(").l ++ inner(byName) ++ plain(")").l
case _ => inner(arg)
partOfSignature ++ keyword(" => ").l ++ inner(rtpe)
partOfSignature ++ keyword(arrow).l ++ inner(rtpe)
case args =>
plain("(").l ++ commas(args.init.map(inner)) ++ plain(")").l ++ keyword(" => ").l ++ inner(args.last)
plain("(").l ++ commas(args.init.map(inner)) ++ plain(")").l ++ keyword(arrow).l ++ inner(args.last)
else if t.isTupleN then
typeList match
case Nil =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ class ContextBounds extends SignatureTest("contextBounds", SignatureTest.all)
class FBoundedTypeParameters extends SignatureTest("fboundedTypeParameters", SignatureTest.all)

class Exports extends SignatureTest("exports2", SignatureTest.all, sourceFiles = List("exports1", "exports2"))

class ContextFunctions extends SignatureTest("contextfunctions", SignatureTest.all)

0 comments on commit f955f8b

Please sign in to comment.