Skip to content

Commit 612e0c1

Browse files
committed
Supress safe initialization warning in Types.scala
This change supresses the following 7 safe-init errors that occur in Types.scala, but are too complicated for the checker to reason about: ``` [error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/core/Types.scala:3951:53 [error] 3951 | val paramInfos: List[TypeBounds] = paramInfosExp(this) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. [error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/core/Types.scala:3952:38 [error] 3952 | val resType: Type = resultTypeExp(this) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. [error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/core/Types.scala:3882:53 [error] 3882 | val paramInfos: List[TypeBounds] = paramInfosExp(this) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. [error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/core/Types.scala:3883:38 [error] 3883 | val resType: Type = resultTypeExp(this) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. [error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/core/Types.scala:3708:47 [error] 3708 | val paramInfos: List[Type] = paramInfosExp(this) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. Calling trace: [error] | -> extends MethodType(paramNames)(paramInfosExp, resultTypeExp) [ Types.scala:3730 ] [error] | -> abstract case class MethodType(paramNames: List[TermName])( [ Types.scala:3701 ] [error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/core/Types.scala:3709:38 [error] 3709 | val resType: Type = resultTypeExp(this) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. Calling trace: [error] | -> extends MethodType(paramNames)(paramInfosExp, resultTypeExp) [ Types.scala:3730 ] [error] | -> abstract case class MethodType(paramNames: List[TermName])( [ Types.scala:3701 ] [error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/core/Types.scala:3017:33 [error] 3017 | val parent: Type = parentExp(this) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. ``` Due to the `this` pointer being passed to an external method during initialization, the initialization checker cannot prove that these are safe. Review by @liufengyun
1 parent e078e79 commit 612e0c1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,7 +3014,7 @@ object Types {
30143014
private[Types] var opened: Boolean = false
30153015
private[Types] var openedTwice: Boolean = false
30163016

3017-
val parent: Type = parentExp(this)
3017+
val parent: Type = parentExp(this: @unchecked)
30183018

30193019
private var myRecThis: RecThis | Null = null
30203020

@@ -3705,8 +3705,8 @@ object Types {
37053705

37063706
type This = MethodType
37073707

3708-
val paramInfos: List[Type] = paramInfosExp(this)
3709-
val resType: Type = resultTypeExp(this)
3708+
val paramInfos: List[Type] = paramInfosExp(this: @unchecked)
3709+
val resType: Type = resultTypeExp(this: @unchecked)
37103710
assert(resType.exists)
37113711

37123712
def companion: MethodTypeCompanion
@@ -3879,8 +3879,8 @@ object Types {
38793879
type This = HKTypeLambda
38803880
def companion: HKTypeLambda.type = HKTypeLambda
38813881

3882-
val paramInfos: List[TypeBounds] = paramInfosExp(this)
3883-
val resType: Type = resultTypeExp(this)
3882+
val paramInfos: List[TypeBounds] = paramInfosExp(this: @unchecked)
3883+
val resType: Type = resultTypeExp(this: @unchecked)
38843884

38853885
private def setVariances(tparams: List[LambdaParam], vs: List[Variance]): Unit =
38863886
if tparams.nonEmpty then
@@ -3948,8 +3948,8 @@ object Types {
39483948
type This = PolyType
39493949
def companion: PolyType.type = PolyType
39503950

3951-
val paramInfos: List[TypeBounds] = paramInfosExp(this)
3952-
val resType: Type = resultTypeExp(this)
3951+
val paramInfos: List[TypeBounds] = paramInfosExp(this: @unchecked)
3952+
val resType: Type = resultTypeExp(this: @unchecked)
39533953

39543954
assert(resType.isInstanceOf[TermType], this)
39553955
assert(paramNames.nonEmpty)

0 commit comments

Comments
 (0)