8000 Fixed use case signature problems in #5054 by VladUreche · Pull Request #45 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Fixed use case signature problems in #5054 #45

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

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 12 additions & 8 deletions src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
8000
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,18 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
else Public()
}
}
def flags = {
val fgs = mutable.ListBuffer.empty[Paragraph]
if (sym.isImplicit) fgs += Paragraph(Text("implicit"))
if (sym.isSealed) fgs += Paragraph(Text("sealed"))
if (!sym.isTrait && (sym hasFlag Flags.ABSTRACT)) fgs += Paragraph(Text("abstract"))
if (!sym.isTrait && (sym hasFlag Flags.DEFERRED)) fgs += Paragraph(Text("abstract"))
if (!sym.isModule && (sym hasFlag Flags.FINAL)) fgs += Paragraph(Text("final"))
fgs.toList
def flags = this match {
// workaround for uninitialized flags in use cases - see SI-5054
case m: NonTemplateMemberEntity if (m.useCaseOf.isDefined) =>
m.useCaseOf.get.flags
case _ =>
val fgs = mutable.ListBuffer.empty[Paragraph]
if (sym.isImplicit) fgs += Paragraph(Text("implicit"))
if (sym.isSealed) fgs += Paragraph(Text("sealed"))
if (!sym.isTrait && (sym hasFlag Flags.ABSTRACT)) fgs += Paragraph(Text("abstract"))
if (!sym.isTrait && (sym hasFlag Flags.DEFERRED)) fgs += Paragraph(Text("abstract"))
if (!sym.isModule && (sym hasFlag Flags.FINAL)) fgs += Paragraph(Text("final"))
fgs.toList
}
def deprecation =
if (sym.isDeprecated)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class SI_5054 {
class SI_5054_q1 {

/**
* A simple comment
Expand All @@ -7,4 +7,4 @@ class SI_5054 {
* @usecase def test(): Int
*/
def test(implicit lost: Int): Int = lost
}
}
10 changes: 10 additions & 0 deletions test/scaladoc/resources/SI_5054_q2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class SI_5054_q2 {

/**
* A simple comment
*
* @param lost a lost parameter
* @usecase def test(): Int
*/
final def test(implicit lost: Int): Int = lost
}
10 changes: 10 additions & 0 deletions test/scaladoc/resources/SI_5054_q3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class SI_5054_q3 {

/**
* A simple comment
*
* @param lost a lost parameter
* @usecase def test(): Int
*/
implicit def test(implicit lost: Int): Int = lost
}
10 changes: 10 additions & 0 deletions test/scaladoc/resources/SI_5054_q4.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
abstract class SI_5054_q4 {

/**
* A simple comment
*
* @param lost a lost parameter
* @usecase def test(): Int
*/
def test(implicit lost: Int): Int
}
10 changes: 10 additions & 0 deletions test/scaladoc/resources/SI_5054_q5.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
trait SI_5054_q5 {

/**
* A simple comment
*
* @param lost a lost parameter
* @usecase def test(): Int
*/
def test(implicit lost: Int): Int = lost
}
10 changes: 10 additions & 0 deletions test/scaladoc/resources/SI_5054_q6.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
trait SI_5054_q6 {

/**
* A simple comment
*
* @param lost a lost parameter
* @usecase def test(): Int
*/
def test(implicit lost: Int): Int
}
64 changes: 60 additions & 4 deletions test/scaladoc/scala/html/HtmlFactoryTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,67 @@ object Test extends Properties("HtmlFactory") {
true
}

property("Use cases should override their original members - valid until signature is added to html") = {
createTemplate("SI_5054.scala") match {
// A piece of the signature - corresponding to the use case
def signature(no: Int, modifier: String) = ("""
<li visbl="pub" name="SI_5054_q""" + no + """#test" data-isabs="false">
<a id="test():Int"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">""" + modifier + """</span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">test</span><span class="params">()</span><span class="result">: <span name="scala.Int" class="extype">Int</span></span>
</span>
</h4>
<p class="shortcomment cmt">[use case] A simple comment
</p>
</li>""").replaceAll("\\s+", "")

property("Use cases should override their original members - TODO: Change when including full signature") = {
createTemplate("SI_5054_q1.scala") match {
case node: scala.xml.Node =>
node.toString.replaceAll("\\s+","").contains(signature(1, ""))
case _ => false
}
}

property("Use cases should keep their flags - final should not be lost") = {
createTemplate("SI_5054_q2.scala") match {
case node: scala.xml.Node =>
node.toString.replaceAll("\\s+","").contains(signature(2, "final"))
case _ => false
}
}

property("Use cases should keep their flags - implicit should not be lost") = {
createTemplate("SI_5054_q3.scala") match {
case node: scala.xml.Node =>
node.toString.replaceAll("\\s+","").contains(signature(3, "implicit"))
case _ => false
}
}

property("Use cases should keep their flags - real abstract should not be lost") = {
createTemplate("SI_5054_q4.scala") match {
case node: scala.xml.Node =>
node.toString.replaceAll("\\s+","").contains(signature(4, "abstract"))
case _ => false
}
}

property("Use cases should keep their flags - traits should not be affected") = {
createTemplate("SI_5054_q5.scala") match {
case node: scala.xml.Node =>
node.toString.replaceAll("\\s+","").contains(signature(5, ""))
case _ => false
}
}

property("Use cases should keep their flags - traits with abstract members should display abstract") = {
createTemplate("SI_5054_q6.scala") match {
case node: scala.xml.Node =>
node.toString.contains("A simple comment") &&
! node.toString.contains("a lost parameter")
node.toString.replaceAll("\\s+","").contains(signature(6, "abstract"))
case _ => false
}
}
Expand Down
0