Skip to content

Give more meaningful names to GADT type symbols #4083

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 9, 2018
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
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/core/NameKinds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,14 @@ object NameKinds {
safePrefix + info.num
}

/** Generate fresh unique name of this kind with given prefix name */
/** Generate fresh unique term name of this kind with given prefix name */
def fresh(prefix: TermName = EmptyTermName)(implicit ctx: Context): TermName =
ctx.freshNames.newName(prefix, this)

/** Generate fresh unique type name of this kind with given prefix name */
def fresh(prefix: TypeName)(implicit ctx: Context): TypeName =
fresh(prefix.toTermName).toTypeName

uniqueNameKinds(separator) = this
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Inferencing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Trees._
import Constants._
import Scopes._
import ProtoTypes._
import NameKinds.WildcardParamName
import NameKinds.UniqueName
import annotation.unchecked
import util.Positions._
import util.{Stats, SimpleIdentityMap}
Expand Down Expand Up @@ -242,7 +242,7 @@ object Inferencing {
if (bounds.hi <:< bounds.lo || bounds.hi.classSymbol.is(Final) || fromScala2x)
tvar.instantiate(fromBelow = false)
else {
val wildCard = ctx.newPatternBoundSymbol(WildcardParamName.fresh().toTypeName, bounds, pos)
val wildCard = ctx.newPatternBoundSymbol(UniqueName.fresh(tvar.origin.paramName), bounds, pos)
tvar.instantiateWith(wildCard.typeRef)
patternBound += wildCard
}
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/gadt-eval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ object Test {
// -- [E007] Type Mismatch Error: tests/neg/gadt-eval.scala:10:6 ------------------
// 10 | (eval(a), eval(a))
// | ^^^^^^^^^^^^^^^^^^
// | found: (_$1, _$1)
// | found: (A$1, A$1)
// | required: T
// |
// | where: T is a type in method eval which is an alias of (_$1, _$2)
// | where: T is a type in method eval which is an alias of (A$1, B$1)
}

def eval2[T](e: Exp[T]): T = e match {
Expand Down