@@ -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)
@@ -1394,8 +1402,10 @@ trait Applications extends Compatibility {
1394
1402
* @param resultType The expected result type of the application
1395
1403
*/
1396
1404
def isApplicableMethodRef (methRef : TermRef , args : List [Tree ], resultType : Type , keepConstraint : Boolean , argMatch : ArgMatch )(using Context ): Boolean = {
1405
+ // println("entered isApplicableMethodRef")
1397
1406
def isApp (using Context ): Boolean =
1398
1407
new ApplicableToTrees (methRef, args, resultType, argMatch).success
1408
+ // println(isApp) // check above ^
1399
1409
if (keepConstraint) isApp else explore(isApp)
1400
1410
}
1401
1411
@@ -1757,23 +1767,30 @@ trait Applications extends Compatibility {
1757
1767
* probability of pruning the search. result type comparisons are neither cheap nor
1758
1768
* do they prune much, on average.
1759
1769
*/
1760
- def adaptByResult (chosen : TermRef , alts : List [TermRef ]) = pt match {
1761
- case pt : FunProto if ! explore(resultConforms(chosen.symbol, chosen, pt.resultType)) =>
1762
- val conformingAlts = alts.filterConserve(alt =>
1763
- (alt ne chosen) && explore(resultConforms(alt.symbol, alt, pt.resultType)))
1764
- conformingAlts match {
1765
- case Nil => chosen
1766
- case alt2 :: Nil => alt2
1767
- case alts2 =>
1768
- resolveOverloaded(alts2, pt) match {
1769
- case alt2 :: Nil => alt2
1770
- case _ => chosen
1771
- }
1772
- }
1773
- case _ => chosen
1774
- }
1770
+ def adaptByResult (chosen : TermRef , alts : List [TermRef ]) =
1771
+ // println("entered adaptByResult")
1772
+ // println(chosen.symbol.showDcl)
1773
+ // println(alts.map(_.symbol.showDcl))
1774
+ pt match {
1775
+ case pt : FunProto if ! explore(resultConforms(chosen.symbol, chosen, pt.resultType)) =>
1776
+ // println("pt funproto")
1777
+ val conformingAlts = alts.filterConserve(alt =>
1778
+ (alt ne chosen) && explore(resultConforms(alt.symbol, alt, pt.resultType)))
1779
+ // println(conformingAlts.map(_.symbol.showDcl))
1780
+ conformingAlts match {
1781
+ case Nil => chosen
1782
+ case alt2 :: Nil => alt2
1783
+ case alts2 =>
1784
+ resolveOverloaded(alts2, pt) match {
1785
+ case alt2 :: Nil => alt2
1786
+ case _ => chosen
1787
+ }
1788
+ }
1789
+ case _ => chosen
1790
+ }
1775
1791
1776
1792
def resolve (alts : List [TermRef ]): List [TermRef ] =
1793
+ // println("enter resolve")
1777
1794
pt match
1778
1795
case pt : FunProto =>
1779
1796
if pt.applyKind == ApplyKind .Using then
@@ -1784,11 +1801,18 @@ trait Applications extends Compatibility {
1784
1801
case _ =>
1785
1802
1786
1803
var found = withoutMode(Mode .ImplicitsEnabled )(resolveOverloaded1(alts, pt))
1804
+ // println("found =")
1805
+ // println(found.map(_.symbol.showDcl))
1787
1806
if found.isEmpty && ctx.mode.is(Mode .ImplicitsEnabled ) then
1807
+ // println("update found")
1788
1808
found = resolveOverloaded1(alts, pt)
1789
1809
found match
1790
- case alt :: Nil => adaptByResult(alt, alts) :: Nil
1791
- case _ => found
1810
+ case alt :: Nil =>
1811
+ // println("resolve1")
1812
+ adaptByResult(alt, alts) :: Nil
1813
+ case _ =>
1814
+ // println("resolve2")
1815
+ found
1792
1816
end resolve
1793
1817
1794
1818
/** Try an apply method, if
@@ -1836,6 +1860,9 @@ trait Applications extends Compatibility {
1836
1860
trace(i " resolve over $alts%, %, pt = $pt" , typr, show = true ) {
1837
1861
record(s " resolveOverloaded1 " , alts.length)
1838
1862
1863
+ // println(pt.show)
1864
+ // println(pt)
1865
+
1839
1866
def isDetermined (alts : List [TermRef ]) = alts.isEmpty || alts.tail.isEmpty
1840
1867
1841
1868
/** The shape of given tree as a type; cannot handle named arguments. */
@@ -1935,16 +1962,25 @@ trait Applications extends Compatibility {
1935
1962
record(" resolveOverloaded.FunProto" , alts.length)
1936
1963
val alts1 = narrowBySize(alts)
1937
1964
// report.log(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
1965
+ // println(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
1938
1966
if isDetermined(alts1) then alts1
1939
1967
else
1940
1968
record(" resolveOverloaded.narrowedBySize" , alts1.length)
1941
1969
val alts2 = narrowByShapes(alts1)
1942
1970
// report.log(i"narrowed by shape: ${alts2.map(_.symbol.showDcl)}%, %")
1943
- if isDetermined(alts2) then alts2
1971
+ // println(i"narrowed by shape: ${alts2.map(_.symbol.showDcl)}%, %")
1972
+ if isDetermined(alts2)
1973
+ then
1974
+ // println("1")
1975
+ // println(alts2.map(_.symbol.showDcl))
1976
+ alts2
1944
1977
else
1945
1978
record(" resolveOverloaded.narrowedByShape" , alts2.length)
1946
1979
pretypeArgs(alts2, pt)
1947
- narrowByTrees(alts2, pt.typedArgs(normArg(alts2, _, _)), resultType)
1980
+ val res = narrowByTrees(alts2, pt.typedArgs(normArg(alts2, _, _)), resultType)
1981
+ // println("2")
1982
+ // println(res.map(_.symbol.showDcl))
1983
+ res
1948
1984
1949
1985
case pt @ PolyProto (targs1, pt1) =>
1950
1986
val alts1 = alts.filterConserve(pt.canInstantiate)
0 commit comments