|
Scala example source code file (TypeToStrings.scala)
The TypeToStrings.scala Scala example source codepackage scala package reflect package internal package tpe import scala.collection.mutable.HashSet private[internal] trait TypeToStrings { self: SymbolTable => /** The maximum number of recursions allowed in toString */ final val maxToStringRecursions = 50 private var _toStringRecursions = 0 def toStringRecursions = _toStringRecursions def toStringRecursions_=(value: Int) = _toStringRecursions = value private var _toStringSubjects = HashSet[Type]() def toStringSubjects = _toStringSubjects protected def typeToString(tpe: Type): String = // if (toStringSubjects contains tpe) { // // handles self-referential anonymous classes and who knows what else // "..." // } // else if (toStringRecursions >= maxToStringRecursions) { devWarning("Exceeded recursion depth attempting to print " + util.shortClassOfInstance(tpe)) if (settings.debug) (new Throwable).printStackTrace "..." } else try { toStringRecursions += 1 // TODO: study performance impact of this cache // to quote Jason: // I'm a little uneasy with the performance impact of the fail-safe. We end up calling Type#toString // when we generate error messages, including, importantly, errors issued during silent mode that are never issued. // toStringSubjects += tpe tpe.safeToString } finally { // toStringSubjects -= tpe toStringRecursions -= 1 } } Other Scala source code examplesHere is a short list of links related to this Scala TypeToStrings.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.