Skip to content

Commit 1e39afd

Browse files
committed
Unify Type.isImplicitMethod with MethodType.isImplicit
1 parent 68c279a commit 1e39afd

File tree

9 files changed

+14
-17
lines changed

9 files changed

+14
-17
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
451451
def mayBeVarGetter(sym: Symbol)(implicit ctx: Context): Boolean = {
452452
def maybeGetterType(tpe: Type): Boolean = tpe match {
453453
case _: ExprType => true
454-
case tpe: MethodType => tpe.isImplicit
454+
case tpe: MethodType => tpe.isImplicitMethod
455455
case tpe: PolyType => maybeGetterType(tpe.resultType)
456456
case _ => false
457457
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,7 @@ object Types {
292292
def isJavaMethod: Boolean = false
293293

294294
/** Is this a MethodType which has implicit parameters */
295-
final def isImplicitMethod: Boolean = this match {
296-
case mt: MethodType => mt.isImplicit
297-
case _ => false
298-
}
295+
def isImplicitMethod: Boolean = false
299296

300297
// ----- Higher-order combinators -----------------------------------
301298

@@ -1326,7 +1323,7 @@ object Types {
13261323
case mt: MethodType if !mt.isDependent || ctx.mode.is(Mode.AllowDependentFunctions) =>
13271324
val formals1 = if (dropLast == 0) mt.paramInfos else mt.paramInfos dropRight dropLast
13281325
defn.FunctionOf(
1329-
formals1 mapConserve (_.underlyingIfRepeated(mt.isJavaMethod)), mt.resultType, mt.isImplicit && !ctx.erasedTypes)
1326+
formals1 mapConserve (_.underlyingIfRepeated(mt.isJavaMethod)), mt.resultType, mt.isImplicitMethod && !ctx.erasedTypes)
13301327
}
13311328

13321329
/** The signature of this type. This is by default NotAMethod,
@@ -2706,7 +2703,7 @@ object Types {
27062703
final def companion: MethodTypeCompanion = MethodType.withKind(kind)
27072704

27082705
final override def isJavaMethod: Boolean = kind is JavaKind
2709-
final def isImplicit: Boolean = kind is ImplicitKind
2706+
final override def isImplicitMethod: Boolean = kind is ImplicitKind
27102707

27112708
val paramInfos = paramInfosExp(this)
27122709
val resType = resultTypeExp(this)

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
182182
case tp: MethodType =>
183183
def paramText(name: TermName, tp: Type) = toText(name) ~ ": " ~ toText(tp)
184184
changePrec(GlobalPrec) {
185-
(if (tp.isImplicit) "(implicit " else "(") ~
185+
(if (tp.isImplicitMethod) "(implicit " else "(") ~
186186
Text((tp.paramNames, tp.paramInfos).zipped map paramText, ", ") ~
187187
(if (tp.resultType.isInstanceOf[MethodType]) ")" else "): ") ~
188188
toText(tp.resultType)

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
308308
val params = (pnames, ptypes, defaults).zipped.map((pname, ptype, isDefault) =>
309309
new api.MethodParameter(pname.toString, apiType(ptype),
310310
isDefault, api.ParameterModifier.Plain))
311-
new api.ParameterList(params.toArray, mt.isImplicit) :: paramLists(restpe, params.length)
311+
new api.ParameterList(params.toArray, mt.isImplicitMethod) :: paramLists(restpe, params.length)
312312
case _ =>
313313
Nil
314314
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
11491149

11501150
/** Drop any implicit parameter section */
11511151
def stripImplicit(tp: Type): Type = tp match {
1152-
case mt: MethodType if mt.isImplicit =>
1152+
case mt: MethodType if mt.isImplicitMethod =>
11531153
resultTypeApprox(mt)
11541154
case pt: PolyType =>
11551155
pt.derivedLambdaType(pt.paramNames, pt.paramInfos, stripImplicit(pt.resultType))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ object EtaExpansion {
145145
ids = ids.init :+ repeated(ids.last)
146146
var body: Tree = Apply(lifted, ids)
147147
mt.resultType match {
148-
case rt: MethodType if !rt.isImplicit => body = PostfixOp(body, Ident(nme.WILDCARD))
148+
case rt: MethodType if !rt.isImplicitMethod => body = PostfixOp(body, Ident(nme.WILDCARD))
149149
case _ =>
150150
}
151151
val fn = untpd.Function(params, body)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ object Implicits {
6565

6666
def discardForView(tpw: Type, argType: Type): Boolean = tpw match {
6767
case mt: MethodType =>
68-
mt.isImplicit ||
68+
mt.isImplicitMethod ||
6969
mt.paramInfos.length != 1 ||
7070
!ctx.typerState.test(argType relaxed_<:< mt.paramInfos.head)
7171
case poly: PolyType =>
7272
// We do not need to call ProtoTypes#constrained on `poly` because
7373
// `refMatches` is always called with mode TypevarsMissContext enabled.
7474
poly.resultType match {
7575
case mt: MethodType =>
76-
mt.isImplicit ||
76+
mt.isImplicitMethod ||
7777
mt.paramInfos.length != 1 ||
7878
!ctx.typerState.test(argType relaxed_<:< wildApprox(mt.paramInfos.head, null, Set.empty))
7979
case rtp =>
@@ -109,7 +109,7 @@ object Implicits {
109109
}
110110

111111
def discardForValueType(tpw: Type): Boolean = tpw.stripPoly match {
112-
case tpw: MethodType => !tpw.isImplicit
112+
case tpw: MethodType => !tpw.isImplicitMethod
113113
case _ => false
114114
}
115115

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ object ProtoTypes {
446446
case poly: PolyType =>
447447
normalize(constrained(poly).resultType, pt)
448448
case mt: MethodType =>
449-
if (mt.isImplicit) normalize(resultTypeApprox(mt), pt)
449+
if (mt.isImplicitMethod) normalize(resultTypeApprox(mt), pt)
450450
else if (mt.isDependent) tp
451451
else {
452452
val rt = normalize(mt.resultType, pt)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
19921992
def adaptNoArgs(wtp: Type): Tree = wtp match {
19931993
case wtp: ExprType =>
19941994
adaptInterpolated(tree.withType(wtp.resultType), pt)
1995-
case wtp: MethodType if wtp.isImplicit && constrainResult(wtp, followAlias(pt)) =>
1995+
case wtp: MethodType if wtp.isImplicitMethod && constrainResult(wtp, followAlias(pt)) =>
19961996
val tvarsToInstantiate = tvarsInParams(tree)
19971997
wtp.paramInfos.foreach(instantiateSelected(_, tvarsToInstantiate))
19981998
val constr = ctx.typerState.constraint
@@ -2109,7 +2109,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
21092109
typed(etaExpand(tree, wtp, arity), pt)
21102110
else if (wtp.paramInfos.isEmpty && isAutoApplied(tree.symbol))
21112111
adaptInterpolated(tpd.Apply(tree, Nil), pt)
2112-
else if (wtp.isImplicit)
2112+
else if (wtp.isImplicitMethod)
21132113
err.typeMismatch(tree, pt)
21142114
else
21152115
missingArgs(wtp)

0 commit comments

Comments
 (0)