Skip to content

Commit 02ed36c

Browse files
committed
address review comments
1 parent 3ea6b24 commit 02ed36c

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

compiler/src/dotty/tools/dotc/typer/Synthesizer.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,14 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
290290
case (Singleton(src1, _), Singleton(src2, _)) => src1 eq src2
291291
case (_: ClassSymbol, _: Singleton) => false
292292

293-
def debug(using Context): String = this match
293+
def show(using Context): String = this match
294294
case ClassSymbol(cls) => i"$cls"
295295
case Singleton(src, _) => i"$src"
296296

297-
object MirrorSource:
297+
private[Synthesizer] object MirrorSource:
298298

299299
/** Reduces a mirroredType to either its most specific ClassSymbol,
300-
* or a TermRef to a singleton value, these are
300+
* or a TermRef to a singleton value. These are
301301
* the base elements required to generate a mirror.
302302
*/
303303
def reduce(mirroredType: Type)(using Context): Either[String, MirrorSource] = mirroredType match
@@ -341,7 +341,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
341341
res <- locally {
342342
if lsrc.isSub(rsrc) then Right(lsrc)
343343
else if rsrc.isSub(lsrc) then Right(rsrc)
344-
else Left(i"its subpart `$tp` is an intersection of unrelated symbols ${lsrc.debug} and ${rsrc.debug}.")
344+
else Left(i"its subpart `$tp` is an intersection of unrelated definitions ${lsrc.show} and ${rsrc.show}.")
345345
}
346346
yield
347347
res
+12-12
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
-- Error: tests/neg/mirror-synthesis-errors-b.scala:21:56 --------------------------------------------------------------
22
21 |val testA = summon[Mirror.ProductOf[Cns[Int] & Sm[Int]]] // error: unreleated
33
| ^
4-
|No given instance of type deriving.Mirror.ProductOf[Cns[Int] & Sm[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[Cns[Int] & Sm[Int]]: type `Cns[Int] & Sm[Int]` is not a generic product because its subpart `Cns[Int] & Sm[Int]` is an intersection of unrelated symbols class Cns and class Sm.
4+
|No given instance of type deriving.Mirror.ProductOf[Cns[Int] & Sm[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[Cns[Int] & Sm[Int]]: type `Cns[Int] & Sm[Int]` is not a generic product because its subpart `Cns[Int] & Sm[Int]` is an intersection of unrelated definitions class Cns and class Sm.
55
-- Error: tests/neg/mirror-synthesis-errors-b.scala:22:56 --------------------------------------------------------------
66
22 |val testB = summon[Mirror.ProductOf[Sm[Int] & Cns[Int]]] // error: unreleated
77
| ^
8-
|No given instance of type deriving.Mirror.ProductOf[Sm[Int] & Cns[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[Sm[Int] & Cns[Int]]: type `Sm[Int] & Cns[Int]` is not a generic product because its subpart `Sm[Int] & Cns[Int]` is an intersection of unrelated symbols class Sm and class Cns.
8+
|No given instance of type deriving.Mirror.ProductOf[Sm[Int] & Cns[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[Sm[Int] & Cns[Int]]: type `Sm[Int] & Cns[Int]` is not a generic product because its subpart `Sm[Int] & Cns[Int]` is an intersection of unrelated definitions class Sm and class Cns.
99
-- Error: tests/neg/mirror-synthesis-errors-b.scala:23:49 --------------------------------------------------------------
1010
23 |val testC = summon[Mirror.Of[Cns[Int] & Sm[Int]]] // error: unreleated
1111
| ^
1212
|No given instance of type deriving.Mirror.Of[Cns[Int] & Sm[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[Cns[Int] & Sm[Int]]:
13-
| * type `Cns[Int] & Sm[Int]` is not a generic product because its subpart `Cns[Int] & Sm[Int]` is an intersection of unrelated symbols class Cns and class Sm.
14-
| * type `Cns[Int] & Sm[Int]` is not a generic sum because its subpart `Cns[Int] & Sm[Int]` is an intersection of unrelated symbols class Cns and class Sm.
13+
| * type `Cns[Int] & Sm[Int]` is not a generic product because its subpart `Cns[Int] & Sm[Int]` is an intersection of unrelated definitions class Cns and class Sm.
14+
| * type `Cns[Int] & Sm[Int]` is not a generic sum because its subpart `Cns[Int] & Sm[Int]` is an intersection of unrelated definitions class Cns and class Sm.
1515
-- Error: tests/neg/mirror-synthesis-errors-b.scala:24:49 --------------------------------------------------------------
1616
24 |val testD = summon[Mirror.Of[Sm[Int] & Cns[Int]]] // error: unreleated
1717
| ^
1818
|No given instance of type deriving.Mirror.Of[Sm[Int] & Cns[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[Sm[Int] & Cns[Int]]:
19-
| * type `Sm[Int] & Cns[Int]` is not a generic product because its subpart `Sm[Int] & Cns[Int]` is an intersection of unrelated symbols class Sm and class Cns.
20-
| * type `Sm[Int] & Cns[Int]` is not a generic sum because its subpart `Sm[Int] & Cns[Int]` is an intersection of unrelated symbols class Sm and class Cns.
19+
| * type `Sm[Int] & Cns[Int]` is not a generic product because its subpart `Sm[Int] & Cns[Int]` is an intersection of unrelated definitions class Sm and class Cns.
20+
| * type `Sm[Int] & Cns[Int]` is not a generic sum because its subpart `Sm[Int] & Cns[Int]` is an intersection of unrelated definitions class Sm and class Cns.
2121
-- Error: tests/neg/mirror-synthesis-errors-b.scala:25:55 --------------------------------------------------------------
2222
25 |val testE = summon[Mirror.ProductOf[Sm[Int] & Nn.type]] // error: unreleated
2323
| ^
24-
|No given instance of type deriving.Mirror.ProductOf[Sm[Int] & Nn.type] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[Sm[Int] & Nn.type]: type `Sm[Int] & Nn.type` is not a generic product because its subpart `Sm[Int] & Nn.type` is an intersection of unrelated symbols class Sm and object Nn.
24+
|No given instance of type deriving.Mirror.ProductOf[Sm[Int] & Nn.type] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[Sm[Int] & Nn.type]: type `Sm[Int] & Nn.type` is not a generic product because its subpart `Sm[Int] & Nn.type` is an intersection of unrelated definitions class Sm and object Nn.
2525
-- Error: tests/neg/mirror-synthesis-errors-b.scala:26:55 --------------------------------------------------------------
2626
26 |val testF = summon[Mirror.ProductOf[Nn.type & Sm[Int]]] // error: unreleated
2727
| ^
28-
|No given instance of type deriving.Mirror.ProductOf[Nn.type & Sm[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[Nn.type & Sm[Int]]: type `Nn.type & Sm[Int]` is not a generic product because its subpart `Nn.type & Sm[Int]` is an intersection of unrelated symbols object Nn and class Sm.
28+
|No given instance of type deriving.Mirror.ProductOf[Nn.type & Sm[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[Nn.type & Sm[Int]]: type `Nn.type & Sm[Int]` is not a generic product because its subpart `Nn.type & Sm[Int]` is an intersection of unrelated definitions object Nn and class Sm.
2929
-- Error: tests/neg/mirror-synthesis-errors-b.scala:27:54 --------------------------------------------------------------
3030
27 |val testG = summon[Mirror.Of[Foo.A.type & Foo.B.type]] // error: unreleated
3131
| ^
3232
|No given instance of type deriving.Mirror.Of[(Foo.A : Foo) & (Foo.B : Foo)] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[(Foo.A : Foo) & (Foo.B : Foo)]:
33-
| * type `(Foo.A : Foo) & (Foo.B : Foo)` is not a generic product because its subpart `(Foo.A : Foo) & (Foo.B : Foo)` is an intersection of unrelated symbols value A and value B.
34-
| * type `(Foo.A : Foo) & (Foo.B : Foo)` is not a generic sum because its subpart `(Foo.A : Foo) & (Foo.B : Foo)` is an intersection of unrelated symbols value A and value B.
33+
| * type `(Foo.A : Foo) & (Foo.B : Foo)` is not a generic product because its subpart `(Foo.A : Foo) & (Foo.B : Foo)` is an intersection of unrelated definitions value A and value B.
34+
| * type `(Foo.A : Foo) & (Foo.B : Foo)` is not a generic sum because its subpart `(Foo.A : Foo) & (Foo.B : Foo)` is an intersection of unrelated definitions value A and value B.
3535
-- Error: tests/neg/mirror-synthesis-errors-b.scala:28:54 --------------------------------------------------------------
3636
28 |val testH = summon[Mirror.Of[Foo.B.type & Foo.A.type]] // error: unreleated
3737
| ^
3838
|No given instance of type deriving.Mirror.Of[(Foo.B : Foo) & (Foo.A : Foo)] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[(Foo.B : Foo) & (Foo.A : Foo)]:
39-
| * type `(Foo.B : Foo) & (Foo.A : Foo)` is not a generic product because its subpart `(Foo.B : Foo) & (Foo.A : Foo)` is an intersection of unrelated symbols value B and value A.
40-
| * type `(Foo.B : Foo) & (Foo.A : Foo)` is not a generic sum because its subpart `(Foo.B : Foo) & (Foo.A : Foo)` is an intersection of unrelated symbols value B and value A.
39+
| * type `(Foo.B : Foo) & (Foo.A : Foo)` is not a generic product because its subpart `(Foo.B : Foo) & (Foo.A : Foo)` is an intersection of unrelated definitions value B and value A.
40+
| * type `(Foo.B : Foo) & (Foo.A : Foo)` is not a generic sum because its subpart `(Foo.B : Foo) & (Foo.A : Foo)` is an intersection of unrelated definitions value B and value A.

tests/run/i15234.scala

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package app {
1313
val Bar: lib.Bar.type = lib.Bar
1414
}
1515

16+
1617
@main def Test =
1718
assert(summon[Mirror.Of[scala.Nil.type]].fromProduct(EmptyTuple) == Nil) // alias scala 2 defined
1819
assert(summon[Mirror.Of[lib.Foo.A.type]].fromProduct(EmptyTuple) == lib.Foo.A) // real mirror

0 commit comments

Comments
 (0)