Skip to content

anonymous given name does not include singleton term references #11175

@rssh

Description

@rssh

Minimized code

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())

}

Output

[info] compiling 1 Scala source to /Users/rssh/tests/dotty/obj_extension/target/scala-3.0.0-RC1/classes ...
[error] -- [E161] Naming Error: /Users/rssh/tests/dotty/obj_extension/src/main/scala/x/Main.scala:16:6 
[error] 16 |given Printer[B.type] with
[error]    |^
[error]    |given_Printer_[ModuleClass]/T is already defined as object given_Printer_/T in /Users/rssh/tests/dotty/obj_extension/src/main/scala/x/Main.scala
[error] 17 |   def print(b:B.type):String = "b"
[error] -- [E008] Not Found Error: /Users/rssh/tests/dotty/obj_extension/src/main/scala/x/Main.scala:24:25 
[error] 24 |    System.out.println(B.print())
[error]    |                       ^^^^^^^
[error]    |value print is not a member of x.B[ModuleClass]/T.
[error]    |An extension method was tried, but could not be fully constructed:
[error]    |
[error]    |    <
[error]    |      <
[error]    |        <<x.print:([T/T](t: T)(using x$1: x.Printer/T[T])(): String/T)>[x.B.type]:
[error]    |          ((t: x.B.type)(using x$1: x.Printer/T[x.B.type])(): String/T)
[error]    |        >
[error]    |      (<x.B:x.B[ModuleClass]/T>):((using x$1: x.Printer/T[x.B.type])(): String/T)>
[error]    |    (
[error]    |      </* missing */summon[x.Printer/T[x.B.type]]:
[error]    |        <error no implicit values were found that match type x.Printer/T[x.B.type]>
[error]    |      >
[error]    |    ):
[error]    |      <error <
[error]    |      <
[error]    |        <<x.print:([T/T](t: T)(using x$1: x.Printer/T[T])(): String/T)>[x.B.type]:
[error]    |          ((t: x.B.type)(using x$1: x.Printer/T[x.B.type])(): String/T)
[error]    |        >
[error]    |      (<x.B:x.B[ModuleClass]/T>):((using x$1: x.Printer/T[x.B.type])(): String/T)>
[error]    |    (
[error]    |      </* missing */summon[x.Printer/T[x.B.type]]:
[error]    |        <error no implicit values were found that match type x.Printer/T[x.B.type]>
[error]    |      >
[error]    |    ):<error no implicit values were found that match type x.Printer/T[x.B.type]>> does not match type ?{ print: ? }>
[error]    |    >    failed with
[error]    |
[error]    |        no implicit argument of type x.Printer/T[x.B.type] was found for parameter x$1 of method print in package x/T
[error] two errors found

Expectation

Should be compiled and run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions