File tree 1 file changed +8
-3
lines changed
compiler/src/dotty/tools/dotc/core
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1685,9 +1685,14 @@ object Types {
1685
1685
case _ => resultType
1686
1686
}
1687
1687
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.
1691
1696
*/
1692
1697
def findFunctionType (using Context ): Type = dealias match
1693
1698
case tp : AndType =>
You can’t perform that action at this time.
0 commit comments