diff --git a/compiler/src/dotty/tools/dotc/core/TypeUtils.scala b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala index cbe4a7f8fd9a..8167bf532e1a 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeUtils.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala @@ -127,8 +127,8 @@ class TypeUtils: case mt: MethodType => mt.isImplicitMethod || mt.resType.takesImplicitParams case _ => false - /** The constructors of this tyoe that that are applicable to `argTypes`, without needing - * an implicit conversion. + /** The constructors of this type that are applicable to `argTypes`, without needing + * an implicit conversion. Curried constructors are always excluded. * @param adaptVarargs if true, allow a constructor with just a varargs argument to * match an empty argument list. */ @@ -144,7 +144,7 @@ class TypeUtils: && atPhaseNoLater(Phases.elimRepeatedPhase)(constr.info.isVarArgsMethod) then // accept missing argument for varargs parameter paramInfos = paramInfos.init - argTypes.corresponds(paramInfos)(_ <:< _) + argTypes.corresponds(paramInfos)(_ <:< _) && !ctpe.resultType.isInstanceOf[MethodType] case _ => false recur(constr.info) diff --git a/tests/neg/i15855.scala b/tests/neg/i15855.scala index ba9112032419..c1d316ccae81 100644 --- a/tests/neg/i15855.scala +++ b/tests/neg/i15855.scala @@ -1,6 +1,3 @@ -// crash.scala -import scala.language.implicitConversions - class MyFunction(args: String) trait MyFunction0[+R] extends MyFunction { @@ -8,3 +5,11 @@ trait MyFunction0[+R] extends MyFunction { } def fromFunction0[R](f: Function0[R]): MyFunction0[R] = () => f() // error + +class MyFunctionWithImplicit(implicit args: String) + +trait MyFunction0WithImplicit[+R] extends MyFunctionWithImplicit { + def apply(): R +} + +def fromFunction1[R](f: Function0[R]): MyFunction0WithImplicit[R] = () => f() // error diff --git a/tests/run/i15855.scala b/tests/run/i15855.scala index 880d6d806132..b67bcb11d18a 100644 --- a/tests/run/i15855.scala +++ b/tests/run/i15855.scala @@ -1,6 +1,3 @@ -// crash.scala -import scala.language.implicitConversions - class MyFunction(args: String*) trait MyFunction0[+R] extends MyFunction {