Skip to content

Commit 995516e

Browse files
committed
Add isMethodWithByNameArgs
1 parent 416b273 commit 995516e

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ class Definitions {
11511151
case info: MethodType =>
11521152
!info.resType.isInstanceOf[MethodOrPoly] && // Has only one parameter list
11531153
!info.isVarArgsMethod &&
1154-
!info.paramInfos.exists(_.isInstanceOf[ExprType]) // No by-name parameters
1154+
!info.isMethodWithByNameArgs // No by-name parameters
11551155
case _ => false
11561156
info match
11571157
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/transform/Recheck.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ abstract class Recheck extends Phase, SymTransformer:
188188
* of `mapExprType`.
189189
*/
190190
def normalizeByName(mbr: SingleDenotation)(using Context): SingleDenotation = mbr.info match
191-
case mt: MethodType if mt.paramInfos.exists(_.isInstanceOf[ExprType]) =>
191+
case mt: MethodType if mt.isMethodWithByNameArgs =>
192192
mbr.derivedSingleDenotation(mbr.symbol,
193193
mt.derivedLambdaType(paramInfos = mt.paramInfos.map(_.mapExprType)))
194194
case _ =>

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)