Skip to content

Commit

Permalink
Various clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
natsukagami committed Dec 12, 2022
1 parent 3c899d2 commit d200a4b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,6 @@ object Types {
(if mt.isErasedMethod && !ctx.erasedTypes then
mt.companion.asInstanceOf[ErasedMethodCompanion].isErased
else List.fill(mt.paramInfos.size) { false }) dropRight dropLast
// println(s"$mt => $isErased")
val result1 = mt.nonDependentResultApprox match {
case res: MethodType => res.toFunctionType(isJava)
case res => res
Expand Down Expand Up @@ -4038,7 +4037,7 @@ object Types {

object MethodType extends MethodTypeCompanion("MethodType") {
def companion(isContextual: Boolean = false, isImplicit: Boolean = false, isErased: List[Boolean] = List()): MethodTypeCompanion =
val hasErased = isErased.exists(_ == true)
val hasErased = isErased.contains(true)
if (isContextual)
if (hasErased) ErasedContextualMethodType(isErased) else ContextualMethodType
else if (isImplicit)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ object Parsers {
if isByNameType(tpt) then
syntaxError(em"parameter of type lambda may not be call-by-name", tpt.span)
TermLambdaTypeTree(params.asInstanceOf[List[ValDef]], resultType)
else if imods.isOneOf(Given | Impure) || erasedArgs.exists(_ == true) then
else if imods.isOneOf(Given | Impure) || erasedArgs.contains(true) then
if imods.is(Given) && params.isEmpty then
syntaxError(em"context function types require at least one parameter", paramSpan)
FunctionWithMods(params, resultType, imods, erasedArgs.toList)
Expand Down Expand Up @@ -1597,7 +1597,7 @@ object Parsers {
erasedArgs.addOne(false)
functionRest(t :: Nil)
else
if (erasedArgs.exists(_ == true) && !t.isInstanceOf[FunctionWithMods])
if (erasedArgs.contains(true) && !t.isInstanceOf[FunctionWithMods])
syntaxError(ErasedTypesCanOnlyBeFunctionTypes(), implicitKwPos(start))
t
end typ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
"("
~ argsText(args.init)
~ ")"
argStr ~ " " ~ arrow(isGiven, isPure) ~ " " ~ argText(args.last, false)
argStr ~ " " ~ arrow(isGiven, isPure) ~ " " ~ argText(args.last)
}

def toTextMethodAsFunction(info: Type, isPure: Boolean): Text = info match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object ContextFunctionResults:
tp.derivedLambdaType(resType = integrateContextResults(tp.resType, crCount))
case defn.ContextFunctionType(argTypes, resType, isErased) =>
val methodType: MethodTypeCompanion =
if isErased.exists(_ == true) then ErasedMethodType(isErased) else MethodType
if isErased.contains(true) then ErasedMethodType(isErased) else MethodType
methodType(argTypes, integrateContextResults(resType, crCount - 1))

/** The total number of parameters of method `sym`, not counting
Expand All @@ -87,7 +87,7 @@ object ContextFunctionResults:
else
val defn.ContextFunctionType(params, resTpe, isErased) = tp: @unchecked
val rest = contextParamCount(resTpe, crCount - 1)
if isErased.exists(_ == true) then isErased.count(_ == false) + rest else params.length + rest
if isErased.contains(true) then isErased.count(_ == false) + rest else params.length + rest

def normalParamCount(tp: Type): Int = tp.widenExpr.stripPoly match
case mt @ MethodType(pnames) =>
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
// companion.isErased
case _ => params.map(_ => false)
}
// println(s"callee type = ${calleeType.widen}")

pt match {
case pt: TypeVar
Expand Down

0 comments on commit d200a4b

Please sign in to comment.