Skip to content

Commit d4306dd

Browse files
committed
Document two aspects suggested by review
1 parent 6e811b4 commit d4306dd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,12 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
168168
* one should use `isSubType(_, _)`.
169169
* `recur` should also not be used to compare approximated versions of the original
170170
* types (as when we go from an abstract type to one of its bounds). In that case
171-
* one should use `isSubType(_, _, a)` where `a` defines the kind of approximation
171+
* one should use `isSubType(_, _, a)` where `a` defines the kind of approximation.
172+
*
173+
* Note: Logicaly, `recur` could be nested in `isSubType`, which would avoid
174+
* the instance state consisting `approx` and `leftRoot`. But then the implemented
175+
* code would have two extra parameters for each of the many calls that go from
176+
* one sub-part of isSubType to another.
172177
*/
173178
protected def recur(tp1: Type, tp2: Type): Boolean = trace(s"isSubType ${traceInfo(tp1, tp2)} $approx", subtyping) {
174179

@@ -1063,6 +1068,12 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
10631068
* type of a synthesized tree before comparing it with an expected type.
10641069
* But no such adaptation is applied for implicit eligibility
10651070
* testing, so we have to compensate.
1071+
*
1072+
* Note: Doing the capture conversion on path types is actually not necessary
1073+
* since we can already deal with the situation through skolemization in Typer#captureWildcards.
1074+
* But performance tests indicate that it's better to do it, since we avoid
1075+
* skolemizations, which are more expensive . And, besides, capture conversion on
1076+
* paths is less intrusive than skolemization.
10661077
*/
10671078
def compareCaptured(arg1: TypeBounds, arg2: Type) = tparam match {
10681079
case tparam: Symbol

0 commit comments

Comments
 (0)