Skip to content

Suppress initialization warnings #15560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/ast/Positioned.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src
if ids != null then
val ownId = nextId
nextId += 1
ids.nn.put(this, ownId)
ids.nn.put(this: @unchecked, ownId)
if ownId == debugId then
println(s"Debug tree (id=$debugId) creation \n$this\n")
println(s"Debug tree (id=$debugId) creation \n${this: @unchecked}\n")
Thread.dumpStack()

allocateId()
Expand Down Expand Up @@ -83,7 +83,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src
* the left, or, if that one does not exist, to the start position of the envelope
* of all children to the right.
*/
def envelope(src: SourceFile, startSpan: Span = NoSpan): Span = this match {
def envelope(src: SourceFile, startSpan: Span = NoSpan): Span = (this: @unchecked) match {
case Trees.Inlined(call, _, _) =>
call.span
case _ =>
Expand All @@ -106,7 +106,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src
}
val limit = productArity
def includeChildren(span: Span, n: Int): Span =
if (n < limit) includeChildren(include(span, productElement(n)), n + 1)
if (n < limit) includeChildren(include(span, productElement(n): @unchecked), n + 1)
else span
val span1 = includeChildren(startSpan, 0)
val span2 =
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 @@ -819,7 +819,7 @@ object Contexts {

@sharable object NoContext extends Context((null: ContextBase | Null).uncheckedNN) {
source = NoSource
override val implicits: ContextualImplicits = new ContextualImplicits(Nil, null, false)(this)
override val implicits: ContextualImplicits = new ContextualImplicits(Nil, null, false)(this: @unchecked)
}

/** A context base defines state and associated methods that exist once per
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/core/NameKinds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ object NameKinds {
case _ => None
}

simpleNameKinds(tag) = this
simpleNameKinds(tag) = this: @unchecked
}

/** The kind of names that get formed by adding a prefix to an underlying name */
Expand Down Expand Up @@ -152,7 +152,7 @@ object NameKinds {

def infoString: String = s"Qualified $separator"

qualifiedNameKinds(tag) = this
qualifiedNameKinds(tag) = this: @unchecked
}

/** An extractor for qualified names of an arbitrary kind */
Expand Down Expand Up @@ -190,7 +190,7 @@ object NameKinds {
else -1
}

numberedNameKinds(tag) = this
numberedNameKinds(tag) = this: @unchecked
}

/** An extractor for numbered names of arbitrary kind */
Expand Down Expand Up @@ -225,7 +225,7 @@ object NameKinds {
def fresh(prefix: TypeName)(using Context): TypeName =
fresh(prefix.toTermName).toTypeName

uniqueNameKinds(separator) = this
uniqueNameKinds(separator) = this: @unchecked
}

/** An extractor for unique names of arbitrary kind */
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ object Names {
enterIfNew(cs, offset, len)
}

addEntryAt(0, EmptyTermName)
addEntryAt(0, EmptyTermName: @unchecked)
end NameTable

/** Hashtable for finding term names quickly. */
Expand Down
9 changes: 3 additions & 6 deletions compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ object Scanners {
errorButContinue("trailing separator is not allowed", offset + litBuf.length - 1)
}

class Scanner(source: SourceFile, override val startFrom: Offset = 0, profile: Profile = NoProfile)(using Context) extends ScannerCommon(source) {
class Scanner(source: SourceFile, override val startFrom: Offset = 0, profile: Profile = NoProfile, allowIndent: Boolean = true)(using Context) extends ScannerCommon(source) {
val keepComments = !ctx.settings.YdropComments.value

/** A switch whether operators at the start of lines can be infix operators */
Expand All @@ -185,10 +185,7 @@ object Scanners {
val indentSyntax =
((if (Config.defaultIndent) !noindentSyntax else ctx.settings.indent.value)
|| rewriteNoIndent)
&& { this match
case self: LookaheadScanner => self.allowIndent
case _ => true
}
&& allowIndent

if (rewrite) {
val s = ctx.settings
Expand Down Expand Up @@ -1093,7 +1090,7 @@ object Scanners {
reset()
next

class LookaheadScanner(val allowIndent: Boolean = false) extends Scanner(source, offset) {
class LookaheadScanner(val allowIndent: Boolean = false) extends Scanner(source, offset, allowIndent = allowIndent) {
override def languageImportContext = Scanner.this.languageImportContext
}

Expand Down
9 changes: 5 additions & 4 deletions compiler/src/dotty/tools/dotc/profile/Profiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(using Context)
def outDir: AbstractFile = ctx.settings.outputDir.value

val id: Int = RealProfiler.idGen.incrementAndGet()
RealProfiler.gcMx foreach {
case emitter: NotificationEmitter => emitter.addNotificationListener(this, null, null)
case gc => println(s"Cant connect gcListener to ${gc.getClass}")
}

private val mainThread = Thread.currentThread()

Expand All @@ -130,6 +126,11 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(using Context)
System.runFinalization()
}

RealProfiler.gcMx foreach {
case emitter: NotificationEmitter => emitter.addNotificationListener(this, null, null)
case gc => println(s"Cant connect gcListener to ${gc.getClass}")
}

reporter.header(this)

override def finished(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object ForwardDepChecks:
stats.foldLeft(outer.levelAndIndex, 0) {(mi, stat) =>
val (m, idx) = mi
val m1 = stat match {
case stat: MemberDef => m.updated(stat.symbol, (this, idx))
case stat: MemberDef => m.updated(stat.symbol, (this: @unchecked, idx))
case _ => m
}
(m1, idx + 1)
Expand Down