Skip to content

Commit 3a8e669

Browse files
committed
Fix comment
1 parent 35f3f9c commit 3a8e669

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,9 +1685,14 @@ object Types {
16851685
case _ => resultType
16861686
}
16871687

1688-
/** Determine the expected function type from the prototype. If multiple
1689-
* function types are found in a union or intersection, their intersection
1690-
* is returned. If no function type is found, Any is returned.
1688+
/** Determine the expected function type from the prototype.
1689+
* If no function type is found, Any is returned. If multiple
1690+
* function types are found in an intersection, their intersection
1691+
* is returned. This works since `&` invokes `TypeComparer.distributeAnd`, which
1692+
* ensures that `(A1 => B1) & (A2 => B2)` simplifies to `(A1 | A2) => (B1 & B2)`,
1693+
* so the result is again a function type. An analogous distribution mechanism
1694+
* does not exist for `|`. Therefore, a union of function types also yields `NoType`,
1695+
* since we cannot determine a single expected function type.
16911696
*/
16921697
def findFunctionType(using Context): Type = dealias match
16931698
case tp: AndType =>

0 commit comments

Comments
 (0)