Skip to content

Commit c156627

Browse files
committed
clarify comment in useCompanionAsSumMirror
1 parent e5bf22e commit c156627

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

+6-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ object SymUtils:
116116
self.linkedClass.exists
117117
&& !self.is(Scala2x)
118118
&& (
119-
// self is from source, or companion is a subtype of Sum
119+
// If the sum type is compiled from source, and `self` is a "generic sum"
120+
// then its companion object will become a sum mirror in `posttyper`. (This method
121+
// can be called from `typer` when summoning a Mirror.)
122+
// However if `self` is from a prior run then we should check that its companion subclasses `Mirror.Sum`.
123+
// e.g. before Scala 3.1, hierarchical sum types were not considered "generic sums", so their
124+
// companion would not cache the mirror. Companions from TASTy will already be typed as `Mirror.Sum`.
120125
self.isDefinedInCurrentRun
121126
|| self.linkedClass.isSubClass(defn.Mirror_SumClass)
122127
)

0 commit comments

Comments
 (0)