Skip to content

Commit 099bf33

Browse files
committed
Exclude some explicit nulls negs tests under tasty
1 parent 5a87908 commit 099bf33

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,12 @@ class TreeUnpickler(reader: TastyReader,
914914

915915
def ta = ctx.typeAssigner
916916

917+
// If explicit nulls is enabled, and the source file did not have explicit
918+
// nulls enabled, nullify the member to allow for compatibility.
919+
def nullify(sym: Symbol) =
920+
if (ctx.explicitNulls && !explicitNulls) then
921+
sym.info = ImplicitNullInterop.nullifyMember(sym, sym.info, sym.is(Enum))
922+
917923
val name = readName()
918924
pickling.println(s"reading def of $name at $start")
919925
val tree: MemberDef = tag match {
@@ -930,10 +936,12 @@ class TreeUnpickler(reader: TastyReader,
930936
else
931937
tpt.tpe
932938
sym.info = methodType(paramss, resType)
939+
nullify(sym)
933940
DefDef(paramDefss, tpt)
934941
case VALDEF =>
935942
val tpt = readTpt()(using localCtx)
936943
sym.info = tpt.tpe
944+
nullify(sym)
937945
ValDef(tpt)
938946
case TYPEDEF | TYPEPARAM =>
939947
if (sym.isClass) {
@@ -971,6 +979,9 @@ class TreeUnpickler(reader: TastyReader,
971979
sym.typeRef.recomputeDenot() // make sure we see the new bounds from now on
972980
else
973981
sym.info = info
982+
if (tag == TYPEPARAM) {
983+
nullify(sym)
984+
}
974985

975986
sym.resetFlag(Provisional)
976987
TypeDef(rhs)
@@ -979,13 +990,10 @@ class TreeUnpickler(reader: TastyReader,
979990
val tpt = readTpt()(using localCtx)
980991
assert(nothingButMods(end))
981992
sym.info = tpt.tpe
993+
nullify(sym)
982994
ValDef(tpt)
983995
}
984996

985-
// If explicit nulls is enabled, and the source file did not have explicit
986-
// nulls enabled, nullify the member to allow for compatibility.
987-
if (ctx.explicitNulls && !explicitNulls) then
988-
sym.info = ImplicitNullInterop.nullifyMember(sym, sym.info, sym.is(Enum))
989997

990998
goto(end)
991999
setSpan(start, tree)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
byname-nullables.scala # identity() flexified
2+
varargs.scala # Array type flexified
3+
flow-conservative.scala # .length flexified
4+
nn-basic.scala # .length flexified but trim rejected
5+
i21380c.scala # .length flexified but replaceAll rejected
6+
unsafe-scope.scala # .length flexified
7+
i17467.scala # Singleton type flexified
8+
i7883.scala # Unsure
9+
from-nullable.scala # Option argument flexified
10+
flow-in-block.scala # .length flexified
11+
array.scala # Type arugment of Array flexified
12+
flow-forward-ref.scala # .length flexified, forward reference error
13+
flow-implicitly.scala # Singleton type flexified
14+
nn.scala # Flexified elided error [!]
15+
flow-basic.scala # .length flexified
16+
17+
unsafe-cast.scala # Array type flexified
18+
unsafe-extensions.scala # Function arguments flexified

compiler/test/dotty/tools/TestSources.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ object TestSources {
4848

4949
def negScala2LibraryTastyExcludelistFile: String = "compiler/test/dotc/neg-scala2-library-tasty.excludelist"
5050
def negInitGlobalScala2LibraryTastyExcludelistFile: String = "compiler/test/dotc/neg-init-global-scala2-library-tasty.excludelist"
51+
def negExplicitNullsScala2LibraryTastyExcludelistFile: String = "compiler/test/dotc/neg-explicit-nulls-scala2-library-tasty.excludelist"
5152

5253
def negScala2LibraryTastyExcludelisted: List[String] =
5354
if Properties.usingScalaLibraryTasty then loadList(negScala2LibraryTastyExcludelistFile)
5455
else Nil
5556
def negInitGlobalScala2LibraryTastyExcludelisted: List[String] =
5657
if Properties.usingScalaLibraryTasty then loadList(negInitGlobalScala2LibraryTastyExcludelistFile)
5758
else Nil
59+
def negExplicitNullsScala2LibraryTastyExcludelisted: List[String] =
60+
if Properties.usingScalaLibraryTasty then loadList(negExplicitNullsScala2LibraryTastyExcludelistFile)
61+
else Nil
62+
5863

5964
// patmat tests lists
6065

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ class CompilationTests {
201201
@Test def explicitNullsNeg: Unit = {
202202
implicit val testGroup: TestGroup = TestGroup("explicitNullsNeg")
203203
aggregateTests(
204-
compileFilesInDir("tests/explicit-nulls/neg", explicitNullsOptions),
204+
compileFilesInDir("tests/explicit-nulls/neg", explicitNullsOptions, FileFilter.exclude(TestSources.negExplicitNullsScala2LibraryTastyExcludelisted)),
205205
compileFilesInDir("tests/explicit-nulls/flexible-types-common", explicitNullsOptions and "-Yno-flexible-types"),
206-
compileFilesInDir("tests/explicit-nulls/unsafe-common", explicitNullsOptions and "-Yno-flexible-types"),
206+
compileFilesInDir("tests/explicit-nulls/unsafe-common", explicitNullsOptions and "-Yno-flexible-types", FileFilter.exclude(TestSources.negExplicitNullsScala2LibraryTastyExcludelisted)),
207207
)
208208
}.checkExpectedErrors()
209209

0 commit comments

Comments
 (0)