Skip to content

Commit 1371940

Browse files
committed
Don't pass type arguments in applicable tests
1 parent aeb7f43 commit 1371940

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,8 @@ trait Applications extends Compatibility {
650650
/** Subclass of Application for applicability tests with type arguments and value
651651
* argument trees.
652652
*/
653-
class ApplicableToTrees(methRef: TermRef, targs: List[Type], args: List[Tree], resultType: Type)(implicit ctx: Context)
654-
extends TestApplication(methRef, methRef.widen.appliedTo(targs), args, resultType) {
653+
class ApplicableToTrees(methRef: TermRef, args: List[Tree], resultType: Type)(implicit ctx: Context)
654+
extends TestApplication(methRef, methRef.widenTermRefExpr, args, resultType) {
655655
def argType(arg: Tree, formal: Type): Type = normalize(arg.tpe, formal)
656656
def treeToArg(arg: Tree): Tree = arg
657657
def isVarArg(arg: Tree): Boolean = tpd.isWildcardStarArg(arg)
@@ -662,7 +662,8 @@ trait Applications extends Compatibility {
662662
/** Subclass of Application for applicability tests with type arguments and value
663663
* argument trees.
664664
*/
665-
class ApplicableToTreesDirectly(methRef: TermRef, targs: List[Type], args: List[Tree], resultType: Type)(implicit ctx: Context) extends ApplicableToTrees(methRef, targs, args, resultType)(ctx) {
665+
class ApplicableToTreesDirectly(methRef: TermRef, args: List[Tree], resultType: Type)(implicit ctx: Context)
666+
extends ApplicableToTrees(methRef, args, resultType)(ctx) {
666667
override def argOK(arg: TypedArg, formal: Type): Boolean =
667668
argType(arg, formal) relaxed_<:< formal.widenExpr
668669
}
@@ -1240,34 +1241,33 @@ trait Applications extends Compatibility {
12401241
def typedUnApply(tree: untpd.UnApply, selType: Type)(implicit ctx: Context): UnApply =
12411242
throw new UnsupportedOperationException("cannot type check an UnApply node")
12421243

1243-
/** Is given method reference applicable to type arguments `targs` and argument trees `args`?
1244+
/** Is given method reference applicable to argument trees `args`?
12441245
* @param resultType The expected result type of the application
12451246
*/
1246-
def isApplicableMethodRef(methRef: TermRef, targs: List[Type], args: List[Tree], resultType: Type, keepConstraint: Boolean)(implicit ctx: Context): Boolean = {
1247+
def isApplicableMethodRef(methRef: TermRef, args: List[Tree], resultType: Type, keepConstraint: Boolean)(implicit ctx: Context): Boolean = {
12471248
def isApp(implicit ctx: Context): Boolean =
1248-
new ApplicableToTrees(methRef, targs, args, resultType).success
1249+
new ApplicableToTrees(methRef, args, resultType).success
12491250
if (keepConstraint) isApp else ctx.test(isApp)
12501251
}
12511252

1252-
/** Is given method reference applicable to type arguments `targs` and argument trees `args` without inferring views?
1253+
/** Is given method reference applicable to argument trees `args` without inferring views?
12531254
* @param resultType The expected result type of the application
12541255
*/
1255-
def isDirectlyApplicableMethodRef(methRef: TermRef, targs: List[Type], args: List[Tree], resultType: Type)(implicit ctx: Context): Boolean =
1256-
ctx.test(new ApplicableToTreesDirectly(methRef, targs, args, resultType).success)
1256+
def isDirectlyApplicableMethodRef(methRef: TermRef, args: List[Tree], resultType: Type)(implicit ctx: Context): Boolean =
1257+
ctx.test(new ApplicableToTreesDirectly(methRef, args, resultType).success)
12571258

12581259
/** Is given method reference applicable to argument types `args`?
12591260
* @param resultType The expected result type of the application
12601261
*/
12611262
def isApplicableMethodRef(methRef: TermRef, args: List[Type], resultType: Type)(implicit ctx: Context): Boolean =
12621263
ctx.test(new ApplicableToTypes(methRef, args, resultType).success)
12631264

1264-
/** Is given type applicable to type arguments `targs` and argument trees `args`,
1265-
* possibly after inserting an `apply`?
1265+
/** Is given type applicable to argument trees `args`, possibly after inserting an `apply`?
12661266
* @param resultType The expected result type of the application
12671267
*/
1268-
def isApplicableType(tp: Type, targs: List[Type], args: List[Tree], resultType: Type, keepConstraint: Boolean)(implicit ctx: Context): Boolean =
1269-
onMethod(tp, targs.nonEmpty || args.nonEmpty) {
1270-
isApplicableMethodRef(_, targs, args, resultType, keepConstraint)
1268+
def isApplicableType(tp: Type, args: List[Tree], resultType: Type, keepConstraint: Boolean)(implicit ctx: Context): Boolean =
1269+
onMethod(tp, args.nonEmpty) {
1270+
isApplicableMethodRef(_, args, resultType, keepConstraint)
12711271
}
12721272

12731273
/** Is given type applicable to argument types `args`, possibly after inserting an `apply`?
@@ -1538,9 +1538,7 @@ trait Applications extends Compatibility {
15381538
}
15391539
}
15401540

1541-
/** Resolve overloaded alternative `alts`, given expected type `pt` and
1542-
* possibly also type argument `targs` that need to be applied to each alternative
1543-
* to form the method type.
1541+
/** Resolve overloaded alternative `alts`, given expected type `pt`.
15441542
* Two trials: First, without implicits or SAM conversions enabled. Then,
15451543
* if the first finds no eligible candidates, with implicits and SAM conversions enabled.
15461544
*/
@@ -1749,11 +1747,11 @@ trait Applications extends Compatibility {
17491747

17501748
def narrowByTrees(alts: List[TermRef], args: List[Tree], resultType: Type): List[TermRef] = {
17511749
val alts2 = alts.filter(alt =>
1752-
isDirectlyApplicableMethodRef(alt, Nil, args, resultType)
1750+
isDirectlyApplicableMethodRef(alt, args, resultType)
17531751
)
17541752
if (alts2.isEmpty && !ctx.isAfterTyper)
17551753
alts.filter(alt =>
1756-
isApplicableMethodRef(alt, Nil, args, resultType, keepConstraint = false)
1754+
isApplicableMethodRef(alt, args, resultType, keepConstraint = false)
17571755
)
17581756
else
17591757
alts2

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ object ProtoTypes {
260260
def isPoly(tree: Tree) = tree.tpe.widenSingleton.isInstanceOf[PolyType]
261261
// See remark in normalizedCompatible for why we can't keep the constraint
262262
// if one of the arguments has a PolyType.
263-
typer.isApplicableType(tp, Nil, args, resultType, keepConstraint && !args.exists(isPoly))
263+
typer.isApplicableType(tp, args, resultType, keepConstraint && !args.exists(isPoly))
264264
}
265265

266266
def derivedFunProto(args: List[untpd.Tree] = this.args, resultType: Type, typer: Typer = this.typer): FunProto =

0 commit comments

Comments
 (0)