Skip to content

Commit 81ff618

Browse files
committed
Address review comments
[Cherry-picked 3af67ba][modified]
1 parent cbbb7e3 commit 81ff618

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ class TypeUtils:
127127
case mt: MethodType => mt.isImplicitMethod || mt.resType.takesImplicitParams
128128
case _ => false
129129

130-
/** The constructors of this tyoe that that are applicable to `argTypes`, without needing
131-
* an implicit conversion.
130+
/** The constructors of this type that are applicable to `argTypes`, without needing
131+
* an implicit conversion. Curried constructors are always excluded.
132132
* @param adaptVarargs if true, allow a constructor with just a varargs argument to
133133
* match an empty argument list.
134134
*/
@@ -144,7 +144,7 @@ class TypeUtils:
144144
&& atPhaseNoLater(Phases.elimRepeatedPhase)(constr.info.isVarArgsMethod)
145145
then // accept missing argument for varargs parameter
146146
paramInfos = paramInfos.init
147-
argTypes.corresponds(paramInfos)(_ <:< _)
147+
argTypes.corresponds(paramInfos)(_ <:< _) && !ctpe.resultType.isInstanceOf[MethodType]
148148
case _ =>
149149
false
150150
recur(constr.info)

tests/neg/i15855.scala

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
// crash.scala
2-
import scala.language.implicitConversions
3-
41
class MyFunction(args: String)
52

63
trait MyFunction0[+R] extends MyFunction {
74
def apply(): R
85
}
96

107
def fromFunction0[R](f: Function0[R]): MyFunction0[R] = () => f() // error
8+
9+
class MyFunctionWithImplicit(implicit args: String)
10+
11+
trait MyFunction0WithImplicit[+R] extends MyFunctionWithImplicit {
12+
def apply(): R
13+
}
14+
15+
def fromFunction1[R](f: Function0[R]): MyFunction0WithImplicit[R] = () => f() // error

tests/run/i15855.scala

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// crash.scala
2-
import scala.language.implicitConversions
3-
41
class MyFunction(args: String*)
52

63
trait MyFunction0[+R] extends MyFunction {

0 commit comments

Comments
 (0)