Skip to content

Remove warnings #3320

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 4 commits into from
Oct 23, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1523,9 +1523,9 @@ object Types {
if (mySig == null) mySig = Signature.NotAMethod
case designator: Symbol =>
uncheckedSetSym(designator)
case LocalName(underlying, space) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the warning valid here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why? =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[warn] -- Warning: /Users/nicolasstucki/GitHub/dotty/compiler/src/dotty/tools/dotc/core/Types.scala:1543:22 
[warn] 1543 |        case LocalName(underlying, space) =>
[warn]      |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn]      |There is no best instantiation of pattern type dotty.tools.dotc.core.Designators.LocalName[dotty.tools.dotc.core.Names.Name]
[warn]      |that makes it a subtype of selector type dotty.tools.dotc.core.Designators.Designator.
[warn]      |Non-variant type variable N cannot be uniquely instantiated.
[warn]      |(This would be an error under strict mode)

We are pattern matching on a Designator { type ThisType <: Name } but we try to match it against a LocalName[N <: Name] { type ThisType = N }. Note that the designator does not define the N type parameter. With these constraints we could instantiate N = Typename or N = TermName.

myNameSpace = space
decompose(underlying)
case designator: LocalName[_] =>
myNameSpace = designator.nameSpace
decompose(designator.name)
}
decompose(designator)
this
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/repl/terminal/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ object FrontEndUtils {
def transpose[A](xs: List[List[A]]): List[List[A]] = {
@tailrec def transpose(xs: List[List[A]], result: List[List[A]]): List[List[A]] = {
xs.filter(_.nonEmpty) match {
case Nil => result
case ys: List[List[A]] => transpose(ys.map(_.tail), ys.map(_.head) :: result)
Copy link
Contributor

@allanrenucci allanrenucci Oct 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a bug. Scalac doesn't report a warning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, we already know that the list is a list of list of A. There is no runtime check needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might due to #3208

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, this is just a warning about erasure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #3323

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I would merge this change as the : List[List[A]] is absolutely useless.

case Nil => result
case ys => transpose(ys.map(_.tail), ys.map(_.head) :: result)
}
}

Expand Down
15 changes: 5 additions & 10 deletions doc-tool/src/dotty/tools/dottydoc/model/references.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ object references {
}
final case class NoLink(title: String, target: String) extends MaterializableLink

object AndOrTypeReference {
def unapply(ref: Reference): Option[(Reference, String, Reference)] = ref match {
case OrTypeReference(left, right) => Some((left, "|", right))
case AndTypeReference(left, right) => Some((left, "&amp;", right))
case _ => None
}
}

implicit class ReferenceShower(val ref: Reference) extends AnyVal {
def showReference: String = ref match {
case TypeReference(title, _, tparams) =>
Expand All @@ -44,8 +36,10 @@ object references {
else ""
}

case AndOrTypeReference(left, part, right) =>
left.showReference + s" $part " + right.showReference
case OrTypeReference(left, right) =>
left.showReference + " | " + right.showReference
case AndTypeReference(left, right) =>
left.showReference + " &amp; " + right.showReference

case FunctionReference(args, ret) =>
if (args.isEmpty)
Expand All @@ -67,6 +61,7 @@ object references {
s"$title: $byName${ref.showReference}$repeated"

case ConstantReference(title) => title
case EmptyReference => ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it ever happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did no happen so far. Will put an assert

}
}
}
7 changes: 5 additions & 2 deletions doc-tool/src/dotty/tools/dottydoc/staticsite/tags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ object tags {
else renderLink(baseurl, tpeLink)
}

case AndOrTypeReference(left, sep, right) =>
s"""${renderReference(left)}<span class="and-or-separator"> $sep </span>${renderReference(right)}"""
case OrTypeReference(left, right) =>
s"""${renderReference(left)}<span class="and-or-separator"> | </span>${renderReference(right)}"""

case AndTypeReference(left, right) =>
s"""${renderReference(left)}<span class="and-or-separator"> &amp; </span>${renderReference(right)}"""

case FunctionReference(args, returnValue) => {
val params =
Expand Down