Skip to content

Commit 93bf1f8

Browse files
committed
Address reviewers comments
1 parent 45d3027 commit 93bf1f8

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ class Definitions {
920920

921921
/** Is `tp` a representation of a (possibly depenent) function type or an alias of such? */
922922
def isFunctionType(tp: Type)(implicit ctx: Context) =
923-
isNonDepFunctionType(tp.dealias.dropDependentRefinement)
923+
isNonDepFunctionType(tp.dropDependentRefinement)
924924

925925
// Specialized type parameters defined for scala.Function{0,1,2}.
926926
private lazy val Function1SpecializedParams: collection.Set[Type] =

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,10 @@ object Types {
10171017
case _ => this
10181018
}
10191019

1020-
/** If this is a dependent function type, drop the `apply` refinement */
1021-
final def dropDependentRefinement(implicit ctx: Context): Type = stripTypeVar match {
1020+
/** Dealias, and if result is a dependent function type, drop the `apply` refinement. */
1021+
final def dropDependentRefinement(implicit ctx: Context): Type = dealias match {
10221022
case RefinedType(parent, nme.apply, _) => parent
1023-
case _ => this
1023+
case tp => tp
10241024
}
10251025

10261026
/** The type constructor of an applied type, otherwise the type itself */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ object Inferencing {
5454
*/
5555
def instantiateDependent(tp: Type, tparams: List[Symbol], vparamss: List[List[Symbol]])(implicit ctx: Context): Unit = {
5656
val dependentVars = new TypeAccumulator[Set[TypeVar]] {
57-
lazy val params = (vparamss :\ tparams)( _ ::: _)
57+
lazy val params = (tparams :: vparamss).flatten
5858
def apply(tvars: Set[TypeVar], tp: Type) = tp match {
5959
case tp: TypeVar
6060
if !tp.isInstantiated &&

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
715715
}
716716
val funCls = defn.FunctionClass(args.length, isImplicit)
717717

718-
def typedDependent(params: List[ValDef])(implicit ctx: Context) = {
718+
/** Typechecks dependent function type with given parameters `params` */
719+
def typedDependent(params: List[ValDef])(implicit ctx: Context): Tree = {
719720
completeParams(params)
720721
val params1 = params.map(typedExpr(_).asInstanceOf[ValDef])
721722
val resultTpt = typed(body)
@@ -744,8 +745,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
744745
}
745746

746747
def typedFunctionValue(tree: untpd.Function, pt: Type)(implicit ctx: Context) = {
747-
val untpd.Function(args, body) = tree
748-
val params = args.asInstanceOf[List[untpd.ValDef]]
748+
val untpd.Function(params: List[untpd.ValDef], body) = tree
749749

750750
pt match {
751751
case pt: TypeVar if untpd.isFunctionWithUnknownParamType(tree) =>
@@ -837,7 +837,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
837837
}
838838
case _ =>
839839
}
840-
errorType(AnonymousFunctionMissingParamType(param, args, tree, pt), param.pos)
840+
errorType(AnonymousFunctionMissingParamType(param, params, tree, pt), param.pos)
841841
}
842842

843843
def protoFormal(i: Int): Type =
@@ -1714,7 +1714,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
17141714
}
17151715

17161716
protected def makeImplicitFunction(tree: untpd.Tree, pt: Type)(implicit ctx: Context): Tree = {
1717-
val defn.FunctionOf(formals, _, true) = pt.dealias.dropDependentRefinement
1717+
val defn.FunctionOf(formals, _, true) = pt.dropDependentRefinement
17181718
val paramTypes = formals.map(fullyDefinedType(_, "implicit function parameter", tree.pos))
17191719
val ifun = desugar.makeImplicitFunction(paramTypes, tree)
17201720
typr.println(i"make implicit function $tree / $pt ---> $ifun")

0 commit comments

Comments
 (0)