Skip to content

Commit 54f5421

Browse files
nicolasstuckiWojciechMazur
authored andcommitted
Add isMethodWithByNameArgs
[Cherry-picked 9966ced]
1 parent 82ff24f commit 54f5421

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
@@ -1163,7 +1163,7 @@ class Definitions {
11631163
case info: MethodType =>
11641164
!info.resType.isInstanceOf[MethodOrPoly] && // Has only one parameter list
11651165
!info.isVarArgsMethod &&
1166-
!info.paramInfos.exists(_.isInstanceOf[ExprType]) // No by-name parameters
1166+
!info.isMethodWithByNameArgs // No by-name parameters
11671167
case _ => false
11681168
info match
11691169
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
@@ -419,6 +419,12 @@ object Types {
419419
case _ => false
420420
}
421421

422+
/** Is this the type of a method that has a by-name parameters? */
423+
def isMethodWithByNameArgs(using Context): Boolean = stripPoly match {
424+
case mt: MethodType => mt.paramInfos.exists(_.isInstanceOf[ExprType])
425+
case _ => false
426+
}
427+
422428
/** Is this the type of a method with a leading empty parameter list?
423429
*/
424430
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
@@ -507,7 +507,7 @@ object Nullables:
507507
def postProcessByNameArgs(fn: TermRef, app: Tree)(using Context): Tree =
508508
fn.widen match
509509
case mt: MethodType
510-
if mt.paramInfos.exists(_.isInstanceOf[ExprType]) && !fn.symbol.is(Inline) =>
510+
if mt.isMethodWithByNameArgs && !fn.symbol.is(Inline) =>
511511
app match
512512
case Apply(fn, args) =>
513513
object dropNotNull extends TreeMap:

0 commit comments

Comments
 (0)