Skip to content
Open
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/NullOpsDecorator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object NullOpsDecorator:

/** Is self (after widening and dealiasing) a type of the form `T | Null`? */
def isNullableUnion(using Context): Boolean = {
val stripped = self.stripNull()
val stripped = self.stripNull(stripFlexibleTypes = false)
stripped ne self
}
end extension
Expand Down
9 changes: 9 additions & 0 deletions tests/explicit-nulls/pos/flow-flexible.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This test is based on sconfig/sconfig/shared/src/main/scala/org/ekrich/config/impl/SimpleConfig.scala
// In cases where a nullable variable is assigned a flexible type, we want
// later code to type the variable access as non-nullable
// Added in https://github.com/scala/scala3/pull/24278

def main() =
var result: String | Null = null
result = "".trim()
result.trim()
Loading