Skip to content

Commit 382e4ce

Browse files
committed
Dependent function types may not be implicit
For the moment we want to rule this out. There are quite a lot of bits we have to think through before we can allow this.
1 parent 33869c3 commit 382e4ce

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ object Types {
13281328
val funType = defn.FunctionOf(
13291329
formals1 mapConserve (_.underlyingIfRepeated(mt.isJavaMethod)),
13301330
mt.nonDependentResultApprox, mt.isImplicitMethod && !ctx.erasedTypes)
1331-
if (mt.isDependent) RefinedType(funType, nme.apply, mt)
1331+
if (mt.isDependent && !mt.isImplicitMethod) RefinedType(funType, nme.apply, mt)
13321332
else funType
13331333
}
13341334

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
719719
completeParams(params)
720720
val params1 = params.map(typedExpr(_).asInstanceOf[ValDef])
721721
val resultTpt = typed(body)
722-
val companion = if (isImplicit) ImplicitMethodType else MethodType
723-
val mt = companion.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
722+
val mt = MethodType.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
724723
if (mt.isParamDependent)
725-
ctx.error(i"$mt is an illegal function type because it has inter-parameter dependencies")
724+
ctx.error(i"$mt is an illegal function type because it has inter-parameter dependencies", tree.pos)
725+
if (isImplicit)
726+
ctx.error(i"dependent function type $mt may not be implicit", tree.pos)
727+
726728
val resTpt = TypeTree(mt.nonDependentResultApprox).withPos(body.pos)
727729
val typeArgs = params1.map(_.tpt) :+ resTpt
728730
val tycon = TypeTree(funCls.typeRef)

0 commit comments

Comments
 (0)