Skip to content

Commit 584c069

Browse files
committed
Try to instantiate pt if this is possible by looking into union/intersection types
1 parent 582366c commit 584c069

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,15 +1921,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19211921
NoType
19221922
}
19231923

1924-
pt match {
1925-
case pt: TypeVar
1926-
if untpd.isFunctionWithUnknownParamType(tree) && !calleeType.exists =>
1927-
// try to instantiate `pt` if this is possible. If it does not
1928-
// work the error will be reported later in `inferredParam`,
1929-
// when we try to infer the parameter type.
1930-
isFullyDefined(pt, ForceDegree.flipBottom)
1931-
case _ =>
1932-
}
1924+
if pt.existsPart(_.isInstanceOf[TypeVar], StopAt.Static)
1925+
&& untpd.isFunctionWithUnknownParamType(tree)
1926+
&& !calleeType.exists then
1927+
// try to instantiate `pt` if this is possible. If it does not
1928+
// work the error will be reported later in `inferredParam`,
1929+
// when we try to infer the parameter type.
1930+
isFullyDefined(pt, ForceDegree.flipBottom)
19331931

19341932
val (protoFormals, resultTpt) = decomposeProtoFunction(pt, params.length, tree.srcPos)
19351933

0 commit comments

Comments
 (0)