Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Sep 17, 2024
1 parent 8aa59f8 commit 3af67ba
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 @@ -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.
*/
Expand All @@ -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)
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 3af67ba

Please sign in to comment.