Skip to content

Commit 6817e7f

Browse files
committed
Relax flow typing checks on FlexibleTypes
1 parent dff62ed commit 6817e7f

35 files changed

+134
-135
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ object Types extends TypeUtils {
382382
/** Is this type guaranteed not to have `null` as a value? */
383383
final def isNotNull(using Context): Boolean = this match {
384384
case tp: ConstantType => tp.value.value != null
385-
case tp: FlexibleType => true
385+
case tp: FlexibleType => false
386386
case tp: ClassInfo => !tp.cls.isNullableClass && !tp.isNothingType
387387
case tp: AppliedType => tp.superType.isNotNull
388388
case tp: TypeBounds => tp.hi.isNotNull

library/src/scala/reflect/Selectable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait Selectable extends scala.Selectable:
2323
final def selectDynamic(name: String): Any =
2424
val rcls = selectedValue.getClass
2525
try
26-
val fld = rcls.getField(NameTransformer.encode(name)).nn
26+
val fld = rcls.getField(NameTransformer.encode(name))
2727
ensureAccessible(fld)
2828
fld.get(selectedValue)
2929
catch case ex: NoSuchFieldException =>
@@ -37,7 +37,7 @@ trait Selectable extends scala.Selectable:
3737
*/
3838
final def applyDynamic(name: String, paramTypes: Class[?]*)(args: Any*): Any =
3939
val rcls = selectedValue.getClass
40-
val mth = rcls.getMethod(NameTransformer.encode(name), paramTypes*).nn
40+
val mth = rcls.getMethod(NameTransformer.encode(name), paramTypes*)
4141
ensureAccessible(mth)
4242
mth.invoke(selectedValue, args.asInstanceOf[Seq[AnyRef]]*)
4343

library/src/scala/util/FromDigits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ object FromDigits {
154154
case ex: NumberFormatException => throw MalformedNumber()
155155
}
156156
if (x.isInfinite) throw NumberTooLarge()
157-
if (x == 0.0d && !zeroFloat.pattern.matcher(digits).nn.matches) throw NumberTooSmall()
157+
if (x == 0.0d && !zeroFloat.pattern.matcher(digits).matches) throw NumberTooSmall()
158158
x
159159
}
160160

presentation-compiler/src/main/dotty/tools/pc/AutoImports.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object AutoImports:
2323
def renameConfigMap(config: PresentationCompilerConfig)(using
2424
Context
2525
): Map[Symbol, String] =
26-
config.symbolPrefixes().nn.asScala.flatMap { (from, to) =>
26+
config.symbolPrefixes().asScala.flatMap { (from, to) =>
2727
val pkg = SemanticdbSymbols.inverseSemanticdbSymbol(from)
2828
val rename = to.stripSuffix(".").stripSuffix("#")
2929
List(pkg, pkg.map(_.moduleClass)).flatten
@@ -253,7 +253,7 @@ object AutoImports:
253253
// see WorksheetProvider.worksheetScala3AdjustmentsForPC
254254
val indent =
255255
if pos.source.path.isWorksheet &&
256-
editPos.getStart().nn.getCharacter() == 0
256+
editPos.getStart().getCharacter() == 0
257257
then indent0.drop(2)
258258
else indent0
259259
val topPadding =

presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ final class AutoImportsProvider(
3030
)(using ReportContext):
3131

3232
def autoImports(isExtension: Boolean): List[AutoImportsResult] =
33-
val uri = params.uri().nn
34-
val text = params.text().nn
33+
val uri = params.uri()
34+
val text = params.text()
3535
val filePath = Paths.get(uri)
3636
driver.run(uri, SourceFile.virtual(filePath.toString, text))
3737

presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CompilerSearchVisitor(
1919
)(using ctx: Context, reports: ReportContext)
2020
extends SymbolSearchVisitor:
2121

22-
val logger: Logger = Logger.getLogger(classOf[CompilerSearchVisitor].getName()).nn
22+
val logger: Logger = Logger.getLogger(classOf[CompilerSearchVisitor].getName())
2323

2424
private def isAccessibleImplicitClass(sym: Symbol) =
2525
val owner = sym.maybeOwner
@@ -77,7 +77,7 @@ class CompilerSearchVisitor(
7777
.split("\\$")
7878

7979
val added =
80-
try toSymbols(pkg, innerPath.nn.toList.map(_.nn)).filter(visitSymbol)
80+
try toSymbols(pkg, innerPath.toList).filter(visitSymbol)
8181
catch
8282
case NonFatal(e) =>
8383
logger.log(Level.WARNING, e.getMessage(), e)

presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object CompletionItemResolver extends ItemResolver:
5050
Context
5151
): String =
5252
def docs(gsym: Symbol): String =
53-
search.symbolDocumentation(gsym).fold("")(_.docstring().nn)
53+
search.symbolDocumentation(gsym).fold("")(_.docstring())
5454
val gsymDoc = docs(gsym)
5555
def keyword(gsym: Symbol): String =
5656
if gsym.isClass then "class"

presentation-compiler/src/main/dotty/tools/pc/ConvertToNamedArgumentsProvider.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ final class ConvertToNamedArgumentsProvider(
2323
):
2424

2525
def convertToNamedArguments: Either[String, List[l.TextEdit]] =
26-
val uri = params.uri().nn
27-
val text = params.text().nn
26+
val uri = params.uri()
27+
val text = params.text()
2828
val filePath = Paths.get(uri)
2929
driver.run(uri, SourceFile.virtual(filePath.toString, text))
3030

presentation-compiler/src/main/dotty/tools/pc/DiagnosticProvider.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DiagnosticProvider(driver: InteractiveDriver, params: VirtualFileParams):
1818

1919
def diagnostics(): List[lsp4j.Diagnostic] =
2020
if params.shouldReturnDiagnostics then
21-
val diags = driver.run(params.uri().nn, params.text().nn)
21+
val diags = driver.run(params.uri(), params.text())
2222
given Context = driver.currentCtx
2323
diags.flatMap(toLsp)
2424
else Nil

presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ final class ExtractMethodProvider(
3939
extends ExtractMethodUtils:
4040

4141
def extractMethod(): List[TextEdit] =
42-
val text = range.text().nn
43-
val uri = range.uri().nn
42+
val text = range.text()
43+
val uri = range.uri()
4444
val filePath = Paths.get(uri)
4545
val source = SourceFile.virtual(filePath.toString, text)
4646
driver.run(uri, source)

0 commit comments

Comments
 (0)