File tree Expand file tree Collapse file tree 2 files changed +62
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +62
-3
lines changed Original file line number Diff line number Diff line change @@ -1566,7 +1566,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1566
1566
case x => x
1567
1567
}
1568
1568
1569
- def sizeFits (alt : TermRef ): Boolean = alt.widen.stripPoly match {
1569
+ def sizeFits (alt : TermRef , followApply : Boolean ): Boolean = alt.widen.stripPoly match {
1570
1570
case tp : MethodType =>
1571
1571
val ptypes = tp.paramInfos
1572
1572
val numParams = ptypes.length
@@ -1577,11 +1577,12 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1577
1577
else if (numParams > numArgs + 1 ) hasDefault
1578
1578
else isVarArgs || hasDefault
1579
1579
case tp =>
1580
- numArgs == 0 || onMethod(tp, followApply = true )(sizeFits)
1580
+ numArgs == 0 ||
1581
+ followApply && onMethod(tp, followApply = true )(sizeFits(_, followApply = false ))
1581
1582
}
1582
1583
1583
1584
def narrowBySize (alts : List [TermRef ]): List [TermRef ] =
1584
- alts.filter(sizeFits)
1585
+ alts.filter(sizeFits(_, followApply = true ) )
1585
1586
1586
1587
def narrowByShapes (alts : List [TermRef ]): List [TermRef ] = {
1587
1588
if (normArgs exists untpd.isFunctionWithUnknownParamType)
Original file line number Diff line number Diff line change @@ -6,4 +6,62 @@ object B {
6
6
def f (x : Any ): Int = 2
7
7
lazy val f = new A {}
8
8
val x = f(null ) // error: ambiguous
9
+ }
10
+
11
+ object Test {
12
+ def f (x : Any ) = 10
13
+ val f : Foo123 = f(1 ) // error: Not found: type Foo123
14
+
15
+ }
16
+
17
+ object Test2 {
18
+ trait A {
19
+ def apply (x : AnyRef ): Int
20
+ }
21
+ object B {
22
+ def f (e : Any ): A = ???
23
+ val f : A = f(null )
24
+ }
25
+ }
26
+
27
+ object Test3 {
28
+ trait A {
29
+ def apply (x : String ): Int
30
+ }
31
+ object B {
32
+ def f (e : CharSequence ): A = ???
33
+ val f : A = f(null )
34
+ }
35
+ }
36
+
37
+
38
+ object Test4 {
39
+ trait A {
40
+ def apply (x : Any ): Int
41
+ }
42
+ object B {
43
+ def f (e : Any ): A = ???
44
+ val f : A = f(null )
45
+ }
46
+ }
47
+
48
+ object Test5 {
49
+ trait A {
50
+ def apply (x : Any ): Int
51
+ }
52
+ object B {
53
+ def f (e : AnyRef ): A = ???
54
+ val f : A = f(null )
55
+ }
56
+ }
57
+
58
+
59
+ object Test6 {
60
+ trait A {
61
+ def apply (x : CharSequence ): Int
62
+ }
63
+ object B {
64
+ def f (e : String ): A = ???
65
+ val f : A = f(null )
66
+ }
9
67
}
You can’t perform that action at this time.
0 commit comments