@@ -404,7 +404,9 @@ trait Applications extends Compatibility {
404
404
private var _ok = true
405
405
406
406
def ok : Boolean = _ok
407
- def ok_= (x : Boolean ): Unit = _ok = x
407
+ def ok_= (x : Boolean ): Unit =
408
+ // if !x then println("set ok to false")
409
+ _ok = x
408
410
409
411
/** The function's type after widening and instantiating polytypes
410
412
* with TypeParamRefs in constraint set
@@ -446,7 +448,9 @@ trait Applications extends Compatibility {
446
448
// match all arguments with corresponding formal parameters
447
449
matchArgs(orderedArgs, methType.paramInfos, 0 )
448
450
case _ =>
449
- if (methType.isError) ok = false
451
+ if (methType.isError) then
452
+ // println("methType.isError")
453
+ ok = false
450
454
else fail(s " $methString does not take parameters " )
451
455
}
452
456
@@ -654,7 +658,7 @@ trait Applications extends Compatibility {
654
658
defn.isFunctionType(argtpe1) && formal.match
655
659
case SAMType (sam) => argtpe <:< sam.toFunctionType(isJava = formal.classSymbol.is(JavaDefined ))
656
660
case _ => false
657
-
661
+ // println(s"argOK($arg,$formal) = ${isCompatible(argtpe, formal)}")
658
662
isCompatible(argtpe, formal)
659
663
// Only allow SAM-conversion to PartialFunction if implicit conversions
660
664
// are enabled. This is necessary to avoid ambiguity between an overload
@@ -688,8 +692,11 @@ trait Applications extends Compatibility {
688
692
final def addArg (arg : TypedArg , formal : Type ): Unit = ok = ok & argOK(arg, formal)
689
693
def makeVarArg (n : Int , elemFormal : Type ): Unit = {}
690
694
def fail (msg : Message , arg : Arg ): Unit =
695
+ // println(msg)
696
+ // println(arg)
691
697
ok = false
692
698
def fail (msg : Message ): Unit =
699
+ // println(msg)
693
700
ok = false
694
701
def appPos : SrcPos = NoSourcePosition
695
702
@ threadUnsafe lazy val normalizedFun : Tree = ref(methRef)
@@ -701,6 +708,7 @@ trait Applications extends Compatibility {
701
708
*/
702
709
class ApplicableToTrees (methRef : TermRef , args : List [Tree ], resultType : Type , argMatch : ArgMatch )(using Context )
703
710
extends TestApplication (methRef, methRef.widen, args, resultType, argMatch) {
711
+ // println("ApplicableToTrees created")
704
712
def argType (arg : Tree , formal : Type ): Type =
705
713
if untpd.isContextualClosure(arg) && defn.isContextFunctionType(formal) then arg.tpe
706
714
else normalize(arg.tpe, formal)
@@ -1385,8 +1393,10 @@ trait Applications extends Compatibility {
1385
1393
* @param resultType The expected result type of the application
1386
1394
*/
1387
1395
def isApplicableMethodRef (methRef : TermRef , args : List [Tree ], resultType : Type , keepConstraint : Boolean , argMatch : ArgMatch )(using Context ): Boolean = {
1396
+ // println("entered isApplicableMethodRef")
1388
1397
def isApp (using Context ): Boolean =
1389
1398
new ApplicableToTrees (methRef, args, resultType, argMatch).success
1399
+ // println(isApp) // check above ^
1390
1400
if (keepConstraint) isApp else explore(isApp)
1391
1401
}
1392
1402
@@ -1748,23 +1758,30 @@ trait Applications extends Compatibility {
1748
1758
* probability of pruning the search. result type comparisons are neither cheap nor
1749
1759
* do they prune much, on average.
1750
1760
*/
1751
- def adaptByResult (chosen : TermRef , alts : List [TermRef ]) = pt match {
1752
- case pt : FunProto if ! explore(resultConforms(chosen.symbol, chosen, pt.resultType)) =>
1753
- val conformingAlts = alts.filterConserve(alt =>
1754
- (alt ne chosen) && explore(resultConforms(alt.symbol, alt, pt.resultType)))
1755
- conformingAlts match {
1756
- case Nil => chosen
1757
- case alt2 :: Nil => alt2
1758
- case alts2 =>
1759
- resolveOverloaded(alts2, pt) match {
1760
- case alt2 :: Nil => alt2
1761
- case _ => chosen
1762
- }
1763
- }
1764
- case _ => chosen
1765
- }
1761
+ def adaptByResult (chosen : TermRef , alts : List [TermRef ]) =
1762
+ // println("entered adaptByResult")
1763
+ // println(chosen.symbol.showDcl)
1764
+ // println(alts.map(_.symbol.showDcl))
1765
+ pt match {
1766
+ case pt : FunProto if ! explore(resultConforms(chosen.symbol, chosen, pt.resultType)) =>
1767
+ // println("pt funproto")
1768
+ val conformingAlts = alts.filterConserve(alt =>
1769
+ (alt ne chosen) && explore(resultConforms(alt.symbol, alt, pt.resultType)))
1770
+ // println(conformingAlts.map(_.symbol.showDcl))
1771
+ conformingAlts match {
1772
+ case Nil => chosen
1773
+ case alt2 :: Nil => alt2
1774
+ case alts2 =>
1775
+ resolveOverloaded(alts2, pt) match {
1776
+ case alt2 :: Nil => alt2
1777
+ case _ => chosen
1778
+ }
1779
+ }
1780
+ case _ => chosen
1781
+ }
1766
1782
1767
1783
def resolve (alts : List [TermRef ]): List [TermRef ] =
1784
+ // println("enter resolve")
1768
1785
pt match
1769
1786
case pt : FunProto =>
1770
1787
if pt.applyKind == ApplyKind .Using then
@@ -1775,11 +1792,18 @@ trait Applications extends Compatibility {
1775
1792
case _ =>
1776
1793
1777
1794
var found = withoutMode(Mode .ImplicitsEnabled )(resolveOverloaded1(alts, pt))
1795
+ // println("found =")
1796
+ // println(found.map(_.symbol.showDcl))
1778
1797
if found.isEmpty && ctx.mode.is(Mode .ImplicitsEnabled ) then
1798
+ // println("update found")
1779
1799
found = resolveOverloaded1(alts, pt)
1780
1800
found match
1781
- case alt :: Nil => adaptByResult(alt, alts) :: Nil
1782
- case _ => found
1801
+ case alt :: Nil =>
1802
+ // println("resolve1")
1803
+ adaptByResult(alt, alts) :: Nil
1804
+ case _ =>
1805
+ // println("resolve2")
1806
+ found
1783
1807
end resolve
1784
1808
1785
1809
/** Try an apply method, if
@@ -1827,6 +1851,9 @@ trait Applications extends Compatibility {
1827
1851
trace(i " resolve over $alts%, %, pt = $pt" , typr, show = true ) {
1828
1852
record(s " resolveOverloaded1 " , alts.length)
1829
1853
1854
+ // println(pt.show)
1855
+ // println(pt)
1856
+
1830
1857
def isDetermined (alts : List [TermRef ]) = alts.isEmpty || alts.tail.isEmpty
1831
1858
1832
1859
/** The shape of given tree as a type; cannot handle named arguments. */
@@ -1926,16 +1953,25 @@ trait Applications extends Compatibility {
1926
1953
record(" resolveOverloaded.FunProto" , alts.length)
1927
1954
val alts1 = narrowBySize(alts)
1928
1955
// report.log(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
1956
+ // println(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
1929
1957
if isDetermined(alts1) then alts1
1930
1958
else
1931
1959
record(" resolveOverloaded.narrowedBySize" , alts1.length)
1932
1960
val alts2 = narrowByShapes(alts1)
1933
1961
// report.log(i"narrowed by shape: ${alts2.map(_.symbol.showDcl)}%, %")
1934
- if isDetermined(alts2) then alts2
1962
+ // println(i"narrowed by shape: ${alts2.map(_.symbol.showDcl)}%, %")
1963
+ if isDetermined(alts2)
1964
+ then
1965
+ // println("1")
1966
+ // println(alts2.map(_.symbol.showDcl))
1967
+ alts2
1935
1968
else
1936
1969
record(" resolveOverloaded.narrowedByShape" , alts2.length)
1937
1970
pretypeArgs(alts2, pt)
1938
- narrowByTrees(alts2, pt.typedArgs(normArg(alts2, _, _)), resultType)
1971
+ val res = narrowByTrees(alts2, pt.typedArgs(normArg(alts2, _, _)), resultType)
1972
+ // println("2")
1973
+ // println(res.map(_.symbol.showDcl))
1974
+ res
1939
1975
1940
1976
case pt @ PolyProto (targs1, pt1) =>
1941
1977
val alts1 = alts.filterConserve(pt.canInstantiate)
0 commit comments