Skip to content

Commit

Permalink
Small change
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Jan 21, 2022
1 parent 1d886e3 commit 0d52503
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
case tp: MethodType =>
val isParamDependent = tp.isParamDependent
val previousParamRefs: ListBuffer[TermRef] =
// It is ok to assign `null` here.
// If `isParamDependent == false`, the value of `previousParamRefs` is not used.
if isParamDependent then mutable.ListBuffer[TermRef]() else null.asInstanceOf

def valueParam(name: TermName, origInfo: Type): TermSymbol =
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ object Constants {
case TypeBounds(lo, hi) =>
if (hi.classSymbol.isPrimitiveValueClass) hi //constrain further with high bound
else classBound(lo)
case NoType => classBound(param.binder.paramInfos(param.paramNum).lo) // TODO
case NoType => classBound(param.binder.paramInfos(param.paramNum).lo)
case inst => classBound(inst)
}
case pt => pt
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ object Contexts {
related = SimpleIdentityMap.empty
null
else
related.nn.apply(key)
related.nn(key)

private def withPhase(phase: Phase, pid: PhaseId): Context =
util.Stats.record("Context.withPhase")
Expand Down
17 changes: 8 additions & 9 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ class Definitions {
val patches = patchCls.info.decls.filter(patch =>
!patch.isConstructor && !patch.isOneOf(PrivateOrSynthetic))
for patch <- patches if !recurse(patch) do
val e: ScopeEntry | Null = scope.lookupEntry(patch.name)
val e = scope.lookupEntry(patch.name)
if e != null then scope.unlink(e)
for patch <- patches do
patch.ensureCompleted()
Expand Down Expand Up @@ -1274,16 +1274,15 @@ class Definitions {
@tu lazy val TupleType: Array[TypeRef] = mkArityArray("scala.Tuple", MaxTupleArity, 1)

private class FunType(prefix: String):
private var classRefs: Array[TypeRef] = new Array(22)
private var classRefs: Array[TypeRef | Null] = new Array(22)
def apply(n: Int): TypeRef =
while n >= classRefs.length do
val classRefs1 = new Array[TypeRef](classRefs.length * 2)
val classRefs1 = new Array[TypeRef | Null](classRefs.length * 2)
Array.copy(classRefs, 0, classRefs1, 0, classRefs.length)
classRefs = classRefs1
val cr: TypeRef | Null = classRefs(n)
if cr == null then
if classRefs(n) == null then
classRefs(n) = requiredClassRef(prefix + n.toString)
classRefs(n)
classRefs(n).nn

private val erasedContextFunType = FunType("scala.ErasedContextFunction")
private val contextFunType = FunType("scala.ContextFunction")
Expand Down Expand Up @@ -1822,15 +1821,15 @@ class Definitions {

@tu lazy val reservedScalaClassNames: Set[Name] = syntheticScalaClasses.map(_.name).toSet

private var isDefnInitialized = false
private var isInitialized = false

def init()(using Context): Unit = {
this.initCtx = ctx
if (!isDefnInitialized) {
if (!isInitialized) {
// force initialization of every symbol that is synthesized or hijacked by the compiler
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses() :+ JavaEnumClass

isDefnInitialized = true
isInitialized = true
}
addSyntheticSymbolsComments
}
Expand Down
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ object Implicits:
* @param companionRefs the companion objects in the implicit scope.
*/
class OfTypeImplicits(tp: Type, override val companionRefs: TermRefSet)(initctx: Context) extends ImplicitRefs(initctx) {
// assert(initctx.typer != null)
// TODO: do we need this assert?
assert((initctx.typer: Typer | Null) != null)
implicits.println(i"implicit scope of type $tp = ${companionRefs.showAsList}%, %")
@threadUnsafe lazy val refs: List[ImplicitRef] = {
val buf = new mutable.ListBuffer[TermRef]
Expand Down Expand Up @@ -1863,7 +1864,7 @@ sealed class TermRefSet(using Context):
if !that.isEmpty then that.foreach(+=)

def foreach[U](f: TermRef => U): Unit =
// TODO
// TODO: do we need to check sym == null?
def handle(sym: TermSymbol | Null, prefixes: Type | List[Type] | Null): Unit =
prefixes match
case prefix: Type => f(TermRef(prefix, sym.uncheckedNN))
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2799,7 +2799,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
object SourceFile extends SourceFileModule {
def current: SourceFile =
val unit = ctx.compilationUnit
if unit == NoCompilationUnit then
if unit eq NoCompilationUnit then
throw new java.lang.UnsupportedOperationException(
"`reflect.SourceFile.current` cannot be called within the TASTy ispector")
else unit.source
Expand Down

0 comments on commit 0d52503

Please sign in to comment.