10000 Add names for boolean literal args · scala/scala@be92c18 · GitHub
[go: up one dir, main page]

Skip to content

Commit be92c18

Browse files
committed
Add names for boolean literal args
1 parent a3762bd commit be92c18

File tree

114 files changed

+367
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+367
-347
lines changed

src/compiler/scala/reflect/macros/contexts/Typers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ trait Typers {
5353

5454
def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree = {
5555
macroLogVerbose(s"inferring implicit value of type $pt, macros = ${!withMacrosDisabled}")
56-
universe.analyzer.inferImplicit(universe.EmptyTree, pt, false, callsiteTyper.context, silent, withMacrosDisabled, pos, (pos, msg) => throw TypecheckException(pos, msg))
56+
universe.analyzer.inferImplicit(universe.EmptyTree, pt, isView = false, callsiteTyper.context, silent, withMacrosDisabled, pos, (pos, msg) => throw TypecheckException(pos, msg))
5757
}
5858

5959
def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree = {
6060
macroLogVerbose(s"inferring implicit view from $from to $to for $tree, macros = ${!withMacrosDisabled}")
6161
val viewTpe = universe.appliedType(universe.definitions.FunctionClass(1).toTypeConstructor, List(from, to))
62-
universe.analyzer.inferImplicit(tree, viewTpe, true, callsiteTyper.context, silent, withMacrosDisabled, pos, (pos, msg) => throw TypecheckException(pos, msg))
62+
universe.analyzer.inferImplicit(tree, viewTpe, isView = true, callsiteTyper.context, silent, withMacrosDisabled, pos, (pos, msg) => throw TypecheckException(pos, msg))
6363
}
6464

6565
def resetLocalAttrs(tree: Tree): Tree = universe.resetAttrs(universe.duplicateAndKeepPositions(tree))

src/compiler/scala/tools/nsc/NewLinePrintWriter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import java.io.{Writer, PrintWriter}
1515

1616
class NewLinePrintWriter(out: Writer, autoFlush: Boolean)
1717
extends PrintWriter(out, autoFlush) {
18-
def this(out: Writer) = this(out, false)
18+
def this(out: Writer) = this(out, autoFlush = false)
1919
override def println(): Unit = { print("\n"); flush() }
2020
}
2121

src/compiler/scala/tools/nsc/PhaseAssembly.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ trait PhaseAssembly {
6262
node
6363
}
6464

65-
def softConnectNodes(frm: Node, to: Node) = connectNodes(Edge(frm, to, false))
66-
def hardConnectNodes(frm: Node, to: Node) = connectNodes(Edge(frm, to, true))
65+
def softConnectNodes(frm: Node, to: Node) = connectNodes(Edge(frm, to, hard = false))
66+
def hardConnectNodes(frm: Node, to: Node) = connectNodes(Edge(frm, to, hard = true))
6767

6868
// Connect the frm and to nodes in the edge and add it to the set of edges.
6969
private def connectNodes(e: Edge): Unit = {

src/compiler/scala/tools/nsc/ast/Printers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ trait Printers extends scala.reflect.internal.Printers { this: Global =>
195195

196196
def asString(t: Tree): String = render(t, newStandardTreePrinter, settings.printtypes, settings.uniqid, settings.Yshowsymowners, settings.Yshowsymkinds)
197197
def asCompactString(t: Tree): String = render(t, newCompactTreePrinter, settings.printtypes, settings.uniqid, settings.Yshowsymowners, settings.Yshowsymkinds)
198-
def asCompactDebugString(t: Tree): String = render(t, newCompactTreePrinter, true, true, true, true)
198+
def asCompactDebugString(t: Tree): String = render(t, newCompactTreePrinter, printTypes = true, printIds = true, printOwners = true, printKinds = true)
199199

200200
def newStandardTreePrinter(writer: PrintWriter): AstTreePrinter = new AstTreePrinter(writer)
201201
def newCompactTreePrinter(writer: PrintWriter): CompactTreePrinter = new CompactTreePrinter(writer)

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ trait ParsersCommon extends ScannersCommon {
4141
// same time; use Parser.unit instead
4242
import global.{currentUnit => _, _}
4343

44-
def newLiteral(const: Any) = Literal(Constant(const))
44+
def newLiteral(value: Any) = Literal(Constant(value))
4545
def literalUnit = gen.mkSyntheticUnit()
4646

4747
/** This is now an abstract class, only to work around the optimizer:
@@ -671,7 +671,7 @@ self =>
671671
acceptStatSep()
672672

673673
def errorTypeTree = setInPos(TypeTree() setType ErrorType)
674-
def errorTermTree = setInPos(newLiteral(null))
674+
def errorTermTree = setInPos(newLiteral(value = null))
675675
def errorPatternTree = setInPos(Ident(nme.WILDCARD))
676676

677677
/** Check that type parameter is not by name or repeated. */
@@ -1629,7 +1629,7 @@ self =>
16291629
r
16301630
} else {
16311631
accept(LPAREN)
1632-
newLiteral(true)
1632+
newLiteral(value = true)
16331633
}
16341634
}
16351635

src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
4646

4747
def emitZeroOf(tk: BType): Unit = {
4848
tk match {
49-
case BOOL => bc.boolconst(false)
49+
case BOOL => bc.boolconst(b=false)
5050
case BYTE |
5151
SHORT |
5252
CHAR |
@@ -349,7 +349,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
349349
val (staticArgs, dynamicArgs) = staticAndDynamicArgs.splitAt(staticAndDynamicArgs.length - numDynamicArgs)
350350
val bootstrapDescriptor = staticHandleFromSymbol(bootstrapMethodRef)
351351
val bootstrapArgs = staticArgs.map({case t @ Literal(c: Constant) => bootstrapMethodArg(c, t.pos) case x => throw new MatchError(x)})
352-
val descriptor = methodBTypeFromMethodType(qual.symbol.info, false)
352+
val descriptor = methodBTypeFromMethodType(qual.symbol.info, isConstructor=false)
353353
genLoadArguments(dynamicArgs, qual.symbol.info.params.map(param => typeToBType(param.info)))
354354
mnode.visitInvokeDynamicInsn(qual.symbol.name.encoded, descriptor.descriptor, bootstrapDescriptor, bootstrapArgs : _*)
355355

src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ abstract class BCodeHelpers extends BCodeIdiomatic {
267267
* must-single-thread
268268
*/
269269
def apply(sym: Symbol, csymCompUnit: CompilationUnit, mainClass: Option[String]): Boolean = sym.hasModuleFlag && {
270-
val warn = mainClass.fold(true)(_ == sym.fullNameString)
270+
val warn = mainClass.fold(ifEmpty = true)(_ == sym.fullNameString)
271271
def warnBadMain(msg: String, pos: Position): Unit = if (warn) runReporting.warning(pos,
272272
s"""|not a valid main method for ${sym.fullName('.')},
273273
| because $msg.

src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,15 +700,17 @@ abstract class BTypes {
700700
})
701701

702702
def isSubtypeOf(other: ClassBType): Either[NoClassBTypeInfo, Boolean] = try {
703-
if (this == other) return Right(true)
703+
def True = Right(true)
704+
def False = Right(false)
705+
if (this == other) return True
704706
if (isInterface.orThrow) {
705-
if (other == ObjectRef) return Right(true) // interfaces conform to Object
706-
if (!other.isInterface.orThrow) return Right(false) // this is an interface, the other is some class other than object. interfaces cannot extend classes, so the result is false.
707+
if (other == ObjectRef) return True // interfaces conform to Object
708+
if (!other.isInterface.orThrow) return False // this is an interface, the other is some class other than object. interfaces cannot extend classes, so the result is false.
707709
// else: this and other are both interfaces. continue to (*)
708710
} else {
709711
val sc = info.orThrow.superClass
710-
if (sc.isDefined && sc.get.isSubtypeOf(other).orThrow) return Right(true) // the superclass of this class conforms to other
711-
if (!other.isInterface.orThrow) return Right(false) // this and other are both classes, and the superclass of this does not conform
712+
if (sc.isDefined && sc.get.isSubtypeOf(other).orThrow) return True // the superclass of this class conforms to other
713+
if (!other.isInterface.orThrow) return False // this and other are both classes, and the superclass of this does not conform
712714
// else: this is a class, the other is an interface. continue to (*)
713715
}
714716

@@ -1151,7 +1153,7 @@ object BTypes {
11511153
}
11521154
}
11531155

1154-
val EmptyInlineInfo = InlineInfo(false, None, SortedMap.empty, None)
1156+
val EmptyInlineInfo = InlineInfo(isEffectivelyFinal = false, sam = None, methodInfos = SortedMap.empty, warning = None)
11551157

11561158
/**
11571159
* Metadata about a method, used by the inliner.

src/compiler/scala/tools/nsc/backend/jvm/opt/ByteCodeRepository.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ abstract class ByteCodeRepository extends PerRunInit {
5656
* Note - although this is typed a mutable.Map, individual simple get and put operations are threadsafe as the
5757
* underlying data structure is synchronized.
5858
*/
59-
val parsedClasses: mutable.Map[InternalName, Either[ClassNotFound, ClassNode]] = recordPerRunCache(LruMap[InternalName, Either[ClassNotFound, ClassNode]](maxCacheSize, true))
59+
val parsedClasses: mutable.Map[InternalName, Either[ClassNotFound, ClassNode]] = recordPerRunCache(LruMap[InternalName, Either[ClassNotFound, ClassNode]](maxCacheSize))
6060

6161
/**
6262
* Contains the internal names of all classes that are defined in Java source files of the current

src/compiler/scala/tools/nsc/backend/jvm/opt/CallGraph.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,14 @@ abstract class CallGraph {
298298
/**
299299
* Just a named tuple used as return type of `analyzeCallsite`.
300300
*/
301-
private case class CallsiteInfo(isStaticallyResolved: Boolean, sourceFilePath: Option[String],
302-
annotatedInline: Boolean, annotatedNoInline: Boolean,
303-
samParamTypes: IntMap[ClassBType],
304-
warning: Option[CalleeInfoWarning])
301+
private case class CallsiteInfo(
302+
isStaticallyResolved: Boolean = false,
303+
sourceFilePath: Option[String] = None,
304+
annotatedInline: Boolean = false,
305+
annotatedNoInline: Boolean = false,
306+
samParamTypes: IntMap[ClassBType] = IntMap.empty,
307+
warning: Option[CalleeInfoWarning],
308+
)
305309

306310
/**
307311
* Analyze a callsite and gather meta-data that can be used for inlining decisions.
@@ -357,12 +361,12 @@ abstract class CallGraph {
357361

358362
case None =>
359363
val warning = MethodInlineInfoMissing(calleeDeclarationClassBType.internalName, calleeMethodNode.name, calleeMethodNode.desc, calleeDeclarationClassBType.info.orThrow.inlineInfo.warning)
360-
CallsiteInfo(false, None, false, false, IntMap.empty, Some(warning))
364+
CallsiteInfo(warning = Some(warning))
361365
}
362366
} catch {
363367
case Invalid(noInfo: NoClassBTypeInfo) =>
364368
val warning = MethodInlineInfoError(calleeDeclarationClassBType.internalName, calleeMethodNode.name, calleeMethodNode.desc, noInfo)
365-
CallsiteInfo(false, None, false, false, IntMap.empty, Some(warning))
369+
CallsiteInfo(warning = Some(warning))
366370
}
367371
}
368372

0 commit comments

Comments
 (0)
0