Skip to content

fix #11175: consider terms in inventTypeName #11179

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
Jan 20, 2021
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
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,9 @@ object desugar {
if (x.isEmpty)
tree match {
case Select(pre, nme.CONSTRUCTOR) => foldOver(x, pre)
case tree: RefTree if tree.name.isTypeName => tree.name.toString
case tree: RefTree =>
if tree.name.isTypeName then tree.name.toString
else s"${tree.name}_type"
case tree: TypeDef => tree.name.toString
case tree: AppliedTypeTree if followArgs && tree.args.nonEmpty =>
s"${apply(x, tree.tpt)}_${extractArgs(tree.args)}"
Expand Down
25 changes: 25 additions & 0 deletions tests/pos/i11175.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package x

trait Printer[T]:
def print(t:T):String

extension[T](t:T)(using Printer[T])
def print():String = summon[Printer[T]].print(t)

object A

object B

given Printer[A.type] with
def print(a:A.type):String = "a"

given Printer[B.type] with
def print(b:B.type):String = "b"


object Main {

def main(args:Array[String]):Unit =
System.out.println(B.print())

}