Skip to content

Commit f3aea49

Browse files
committed
Try to instantiate pt if this is possible by looking into union/intersection types
1 parent 714f3b6 commit f3aea49

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
@@ -1929,15 +1929,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19291929
NoType
19301930
}
19311931

1932-
pt.stripNull() match {
1933-
case pt: TypeVar
1934-
if untpd.isFunctionWithUnknownParamType(tree) && !calleeType.exists =>
1935-
// try to instantiate `pt` if this is possible. If it does not
1936-
// work the error will be reported later in `inferredParam`,
1937-
// when we try to infer the parameter type.
1938-
isFullyDefined(pt, ForceDegree.flipBottom)
1939-
case _ =>
1940-
}
1932+
if pt.existsPart(_.isInstanceOf[TypeVar], StopAt.Static)
1933+
&& untpd.isFunctionWithUnknownParamType(tree)
1934+
&& !calleeType.exists then
1935+
// try to instantiate `pt` if this is possible. If it does not
1936+
// work the error will be reported later in `inferredParam`,
1937+
// when we try to infer the parameter type.
1938+
isFullyDefined(pt, ForceDegree.flipBottom)
19411939

19421940
val (protoFormals, resultTpt) = decomposeProtoFunction(pt, params.length, tree.srcPos)
19431941

0 commit comments

Comments
 (0)