From 3af67baa337ac8791326fd7b94a752495bdd0f57 Mon Sep 17 00:00:00 2001 From: odersky Date: Tue, 17 Sep 2024 17:54:39 +0200 Subject: [PATCH] Address review comments --- compiler/src/dotty/tools/dotc/core/TypeUtils.scala | 6 +++--- tests/neg/i15855.scala | 11 ++++++++--- tests/run/i15855.scala | 3 --- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/TypeUtils.scala b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala index 33743868b2bc..485272fe71c5 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeUtils.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala @@ -191,8 +191,8 @@ class TypeUtils: case self: RefinedOrRecType => self.parent.stripRefinement case seld => self - /** 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. */ @@ -208,7 +208,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 {