New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependent function types #3464

Merged
merged 13 commits into from Nov 27, 2017

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.
  • Loading branch information...
odersky committed Nov 12, 2017
commit 382e4cefe09972bf4e40e99f795dab823d91b65a
@@ -1328,7 +1328,7 @@ object Types {
val funType = defn.FunctionOf(
formals1 mapConserve (_.underlyingIfRepeated(mt.isJavaMethod)),
mt.nonDependentResultApprox, mt.isImplicitMethod && !ctx.erasedTypes)
if (mt.isDependent) RefinedType(funType, nme.apply, mt)
if (mt.isDependent && !mt.isImplicitMethod) RefinedType(funType, nme.apply, mt)
else funType
}
@@ -719,10 +719,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
completeParams(params)
val params1 = params.map(typedExpr(_).asInstanceOf[ValDef])
val resultTpt = typed(body)
val companion = if (isImplicit) ImplicitMethodType else MethodType
val mt = companion.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
val mt = MethodType.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
if (mt.isParamDependent)
ctx.error(i"$mt is an illegal function type because it has inter-parameter dependencies")
ctx.error(i"$mt is an illegal function type because it has inter-parameter dependencies", tree.pos)
if (isImplicit)
ctx.error(i"dependent function type $mt may not be implicit", tree.pos)
val resTpt = TypeTree(mt.nonDependentResultApprox).withPos(body.pos)
val typeArgs = params1.map(_.tpt) :+ resTpt
val tycon = TypeTree(funCls.typeRef)
ProTip! Use n and p to navigate between commits in a pull request.