Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
[Cherry-picked 3af67ba][modified]
  • Loading branch information
WojciechMazur committed Dec 3, 2024
1 parent cbbb7e3 commit 81ff618
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/TypeUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions tests/neg/i15855.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// crash.scala
import scala.language.implicitConversions

class MyFunction(args: String)

trait MyFunction0[+R] extends MyFunction {
def apply(): R
}

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
3 changes: 0 additions & 3 deletions tests/run/i15855.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// crash.scala
import scala.language.implicitConversions

class MyFunction(args: String*)

trait MyFunction0[+R] extends MyFunction {
Expand Down

0 comments on commit 81ff618

Please sign in to comment.