Skip to content

Commit eb8fba4

Browse files
committed
Simplify use of toFunctionType
Make `isJava` by default false.
1 parent ea1d8f9 commit eb8fba4

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ class CheckCaptures extends Recheck, SymTransformer:
698698

699699
private def toDepFun(args: List[Type], resultType: Type, isContextual: Boolean)(using Context): Type =
700700
MethodType.companion(isContextual = isContextual)(args, resultType)
701-
.toFunctionType(isJava = false, alwaysDependent = true)
701+
.toFunctionType(alwaysDependent = true)
702702

703703
/** Turn `expected` into a dependent function when `actual` is dependent. */
704704
private def alignDependentFunction(expected: Type, actual: Type)(using Context): Type =
@@ -850,7 +850,7 @@ class CheckCaptures extends Recheck, SymTransformer:
850850
adaptFun(actual, rinfo.paramInfos, rinfo.resType, expected, covariant, insertBox,
851851
(aargs1, ares1) =>
852852
rinfo.derivedLambdaType(paramInfos = aargs1, resType = ares1)
853-
.toFunctionType(isJava = false, alwaysDependent = true))
853+
.toFunctionType(alwaysDependent = true))
854854
case actual: MethodType =>
855855
adaptFun(actual, actual.paramInfos, actual.resType, expected, covariant, insertBox,
856856
(aargs1, ares1) =>

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extends tpd.TreeTraverser:
4040
MethodType.companion(
4141
isContextual = defn.isContextFunctionClass(tycon.classSymbol),
4242
)(argTypes, resType)
43-
.toFunctionType(isJava = false, alwaysDependent = true)
43+
.toFunctionType(alwaysDependent = true)
4444

4545
/** If `tp` is an unboxed capturing type or a function returning an unboxed capturing type,
4646
* convert it to be boxed.
@@ -57,7 +57,7 @@ extends tpd.TreeTraverser:
5757
case tp1 @ RefinedType(_, _, rinfo: MethodType) if defn.isFunctionType(tp1) =>
5858
val boxedRinfo = recur(rinfo)
5959
if boxedRinfo eq rinfo then tp
60-
else boxedRinfo.toFunctionType(isJava = false, alwaysDependent = true)
60+
else boxedRinfo.toFunctionType(alwaysDependent = true)
6161
case tp1: MethodOrPoly =>
6262
val res = tp1.resType
6363
val boxedRes = recur(res)
@@ -151,7 +151,7 @@ extends tpd.TreeTraverser:
151151
tp.derivedAppliedType(tycon1, args.mapConserve(arg => this(arg)))
152152
case tp @ RefinedType(core, rname, rinfo: MethodType) if defn.isFunctionType(tp) =>
153153
val rinfo1 = apply(rinfo)
154-
if rinfo1 ne rinfo then rinfo1.toFunctionType(isJava = false, alwaysDependent = true)
154+
if rinfo1 ne rinfo then rinfo1.toFunctionType(alwaysDependent = true)
155155
else tp
156156
case tp: MethodType =>
157157
tp.derivedLambdaType(

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1873,11 +1873,12 @@ object Types {
18731873

18741874
/** Turn type into a function type.
18751875
* @pre this is a method type without parameter dependencies.
1876+
* @param isJava translate repeated params as as java `Array`s?
18761877
* @param dropLast the number of trailing parameters that should be dropped
18771878
* when forming the function type.
18781879
* @param alwaysDependent if true, always create a dependent function type.
18791880
*/
1880-
def toFunctionType(isJava: Boolean, dropLast: Int = 0, alwaysDependent: Boolean = false)(using Context): Type = this match {
1881+
def toFunctionType(isJava: Boolean = false, dropLast: Int = 0, alwaysDependent: Boolean = false)(using Context): Type = this match {
18811882
case mt: MethodType =>
18821883
assert(!mt.isParamDependent)
18831884
def nonDependentFunType =

compiler/src/dotty/tools/dotc/transform/Recheck.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ abstract class Recheck extends Phase, SymTransformer:
333333

334334
def recheckClosure(tree: Closure, pt: Type)(using Context): Type =
335335
if tree.tpt.isEmpty then
336-
tree.meth.tpe.widen.toFunctionType(tree.meth.symbol.is(JavaDefined))
336+
tree.meth.tpe.widen.toFunctionType(isJava = tree.meth.symbol.is(JavaDefined))
337337
else
338338
recheck(tree.tpt)
339339

compiler/src/dotty/tools/dotc/transform/Splicing.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class Splicing extends MacroTransform:
197197
if tree.isTerm then
198198
if isCaptured(tree.symbol) then
199199
val tpe = tree.tpe.widenTermRefExpr match {
200-
case tpw: MethodicType => tpw.toFunctionType(isJava = false)
200+
case tpw: MethodicType => tpw.toFunctionType()
201201
case tpw => tpw
202202
}
203203
spliced(tpe)(capturedTerm(tree))
@@ -291,7 +291,7 @@ class Splicing extends MacroTransform:
291291

292292
private def capturedTerm(tree: Tree)(using Context): Tree =
293293
val tpe = tree.tpe.widenTermRefExpr match
294-
case tpw: MethodicType => tpw.toFunctionType(isJava = false)
294+
case tpw: MethodicType => tpw.toFunctionType()
295295
case tpw => tpw
296296
capturedTerm(tree, tpe)
297297

0 commit comments

Comments
 (0)