Skip to content

Commit 9966ced

Browse files
committed
Add isMethodWithByNameArgs
1 parent e5ca0c4 commit 9966ced

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ class Definitions {
11661166
case info: MethodType =>
11671167
!info.resType.isInstanceOf[MethodOrPoly] && // Has only one parameter list
11681168
!info.isVarArgsMethod &&
1169-
!info.paramInfos.exists(_.isInstanceOf[ExprType]) // No by-name parameters
1169+
!info.isMethodWithByNameArgs // No by-name parameters
11701170
case _ => false
11711171
info match
11721172
case info: PolyType => isValidMethodType(info.resType)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ object Types {
429429
case _ => false
430430
}
431431

432+
/** Is this the type of a method that has a by-name parameters? */
433+
def isMethodWithByNameArgs(using Context): Boolean = stripPoly match {
434+
case mt: MethodType => mt.paramInfos.exists(_.isInstanceOf[ExprType])
435+
case _ => false
436+
}
437+
432438
/** Is this the type of a method with a leading empty parameter list?
433439
*/
434440
def isNullaryMethod(using Context): Boolean = stripPoly match {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ object Nullables:
518518
def postProcessByNameArgs(fn: TermRef, app: Tree)(using Context): Tree =
519519
fn.widen match
520520
case mt: MethodType
521-
if mt.paramInfos.exists(_.isInstanceOf[ExprType]) && !fn.symbol.is(Inline) =>
521+
if mt.isMethodWithByNameArgs && !fn.symbol.is(Inline) =>
522522
app match
523523
case Apply(fn, args) =>
524524
object dropNotNull extends TreeMap:

0 commit comments

Comments
 (0)