Skip to content

Commit

Permalink
Use isScala3Cross
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Jan 30, 2024
1 parent 386cde3 commit d1986de
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
final def forArgMode(fun: Tree, mode: Mode) =
if (treeInfo.isSelfOrSuperConstrCall(fun)) mode | SCCmode else mode

def isScala3cross = currentRun.isScala3 && settings.source.value > scala.tools.nsc.settings.SpecificScalaVersion(3, 0, 0, scala.tools.nsc.settings.Final)

final val shortenImports = false

// All typechecked RHS of ValDefs for right-associative operator desugaring
Expand Down Expand Up @@ -1138,7 +1136,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (settings.isDebug && settings.explaintypes.value) explainTypes(tree.tpe, pt)
if (err ne null) context.issue(err)
if (tree.tpe.isErroneous || pt.isErroneous) setError(tree)
else if (isScala3cross && isFunctionType(pt) && tree.symbol.isModule && tree.symbol.companion.isCase)
else if (currentRun.isScala3Cross && isFunctionType(pt) && tree.symbol.isModule && tree.symbol.companion.isCase)
adaptApplyInsertion()
else adaptMismatchedSkolems()
}
Expand Down Expand Up @@ -5374,7 +5372,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper

// If they try C.tupled, make it (C.apply _).tupled
def fixUpCaseTupled(qual: Tree, name: Name, mode: Mode): Tree =
if (qual.symbol != null && isScala3cross && qual.symbol.isModule && qual.symbol.companion.isCase &&
if (qual.symbol != null && currentRun.isScala3Cross && qual.symbol.isModule && qual.symbol.companion.isCase &&
context.undetparams.isEmpty && fixableFunctionMembers.contains(name)) {
val t = Select(qual, nme.apply)
val t1 = typedSelect(t, qual, nme.apply)
Expand Down
5 changes: 1 addition & 4 deletions src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,11 @@ trait Unapplies extends ast.TreeDSL {
else Default
}

private def isScala3cross =
currentRun.isScala3 && settings.source.value > scala.tools.nsc.settings.SpecificScalaVersion(3, 0, 0, scala.tools.nsc.settings.Final)

/** The module corresponding to a case class; overrides toString to show the module's name
*/
def caseModuleDef(cdef: ClassDef): ModuleDef = {
val params = constrParamss(cdef)
def inheritFromFun = !isScala3cross && !cdef.mods.hasAbstractFlag && cdef.tparams.isEmpty && (params match {
def inheritFromFun = !currentRun.isScala3Cross && !cdef.mods.hasAbstractFlag && cdef.tparams.isEmpty && (params match {
case List(ps) if ps.length <= MaxFunctionArity => true
case _ => false
}) && applyAccess(constrMods(cdef)) != Inherit
Expand Down

0 comments on commit d1986de

Please sign in to comment.