Skip to content

Commit cde3d13

Browse files
authored
Merge pull request #15560 from dotty-staging/reduce-init-warnings
Suppress initialization warnings
2 parents 5f0fff8 + 5c61409 commit cde3d13

File tree

7 files changed

+19
-21
lines changed

7 files changed

+19
-21
lines changed

compiler/src/dotty/tools/dotc/ast/Positioned.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src
3232
if ids != null then
3333
val ownId = nextId
3434
nextId += 1
35-
ids.nn.put(this, ownId)
35+
ids.nn.put(this: @unchecked, ownId)
3636
if ownId == debugId then
37-
println(s"Debug tree (id=$debugId) creation \n$this\n")
37+
println(s"Debug tree (id=$debugId) creation \n${this: @unchecked}\n")
3838
Thread.dumpStack()
3939

4040
allocateId()
@@ -83,7 +83,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src
8383
* the left, or, if that one does not exist, to the start position of the envelope
8484
* of all children to the right.
8585
*/
86-
def envelope(src: SourceFile, startSpan: Span = NoSpan): Span = this match {
86+
def envelope(src: SourceFile, startSpan: Span = NoSpan): Span = (this: @unchecked) match {
8787
case Trees.Inlined(call, _, _) =>
8888
call.span
8989
case _ =>
@@ -106,7 +106,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src
106106
}
107107
val limit = productArity
108108
def includeChildren(span: Span, n: Int): Span =
109-
if (n < limit) includeChildren(include(span, productElement(n)), n + 1)
109+
if (n < limit) includeChildren(include(span, productElement(n): @unchecked), n + 1)
110110
else span
111111
val span1 = includeChildren(startSpan, 0)
112112
val span2 =

compiler/src/dotty/tools/dotc/core/Contexts.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ object Contexts {
819819

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

825825
/** A context base defines state and associated methods that exist once per

compiler/src/dotty/tools/dotc/core/NameKinds.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ object NameKinds {
8585
case _ => None
8686
}
8787

88-
simpleNameKinds(tag) = this
88+
simpleNameKinds(tag) = this: @unchecked
8989
}
9090

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

153153
def infoString: String = s"Qualified $separator"
154154

155-
qualifiedNameKinds(tag) = this
155+
qualifiedNameKinds(tag) = this: @unchecked
156156
}
157157

158158
/** An extractor for qualified names of an arbitrary kind */
@@ -190,7 +190,7 @@ object NameKinds {
190190
else -1
191191
}
192192

193-
numberedNameKinds(tag) = this
193+
numberedNameKinds(tag) = this: @unchecked
194194
}
195195

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

228-
uniqueNameKinds(separator) = this
228+
uniqueNameKinds(separator) = this: @unchecked
229229
}
230230

231231
/** An extractor for unique names of arbitrary kind */

compiler/src/dotty/tools/dotc/core/Names.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ object Names {
568568
enterIfNew(cs, offset, len)
569569
}
570570

571-
addEntryAt(0, EmptyTermName)
571+
addEntryAt(0, EmptyTermName: @unchecked)
572572
end NameTable
573573

574574
/** Hashtable for finding term names quickly. */

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

+3-6
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ object Scanners {
162162
errorButContinue("trailing separator is not allowed", offset + litBuf.length - 1)
163163
}
164164

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

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

193190
if (rewrite) {
194191
val s = ctx.settings
@@ -1093,7 +1090,7 @@ object Scanners {
10931090
reset()
10941091
next
10951092

1096-
class LookaheadScanner(val allowIndent: Boolean = false) extends Scanner(source, offset) {
1093+
class LookaheadScanner(val allowIndent: Boolean = false) extends Scanner(source, offset, allowIndent = allowIndent) {
10971094
override def languageImportContext = Scanner.this.languageImportContext
10981095
}
10991096

compiler/src/dotty/tools/dotc/profile/Profiler.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(using Context)
100100
def outDir: AbstractFile = ctx.settings.outputDir.value
101101

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

108104
private val mainThread = Thread.currentThread()
109105

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

129+
RealProfiler.gcMx foreach {
130+
case emitter: NotificationEmitter => emitter.addNotificationListener(this, null, null)
131+
case gc => println(s"Cant connect gcListener to ${gc.getClass}")
132+
}
133+
133134
reporter.header(this)
134135

135136
override def finished(): Unit = {

compiler/src/dotty/tools/dotc/transform/ForwardDepChecks.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object ForwardDepChecks:
3131
stats.foldLeft(outer.levelAndIndex, 0) {(mi, stat) =>
3232
val (m, idx) = mi
3333
val m1 = stat match {
34-
case stat: MemberDef => m.updated(stat.symbol, (this, idx))
34+
case stat: MemberDef => m.updated(stat.symbol, (this: @unchecked, idx))
3535
case _ => m
3636
}
3737
(m1, idx + 1)

0 commit comments

Comments
 (0)