Skip to content

Commit 73ba485

Browse files
authored
Refactor the abstract domain of global init checker to compile http4s (#22179)
This is a draft PR that contains fixes to the initialization checker, so that it can successfully check http4s in community-build [test_scala2_library_tasty]
2 parents 8b04ba8 + 773880f commit 73ba485

18 files changed

+361
-108
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 288 additions & 98 deletions
Large diffs are not rendered by default.

compiler/test/dotc/neg-init-global-scala2-library-tasty.excludelist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
## See #18882
22
patmat.scala
33
t9312.scala
4-
unapplySeq-implicit-arg.scala
5-
unapplySeq-implicit-arg2.scala
6-
unapplySeq-implicit-arg3.scala
74
ScalaCheck.scala
85
mutable-read8.scala
96
TypeCast.scala

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ class CompilationTests {
233233
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
234234
compileFilesInDir("tests/init-global/warn", defaultOptions.and("-Ysafe-init-global"), FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyExcludelisted)).checkWarnings()
235235
compileFilesInDir("tests/init-global/pos", defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings"), FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyExcludelisted)).checkCompile()
236+
if Properties.usingScalaLibraryTasty && !Properties.usingScalaLibraryCCTasty then
237+
compileFilesInDir("tests/init-global/warn-tasty", defaultOptions.and("-Ysafe-init-global"), FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyExcludelisted)).checkWarnings()
238+
compileFilesInDir("tests/init-global/pos-tasty", defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings"), FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyExcludelisted)).checkCompile()
239+
end if
236240
}
237241

238242
// initialization tests
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object A:
2+
val a = f(10)
3+
val b = -a
4+
val c = b.toDouble
5+
def f(x: Int) = x * 2 + 5
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package p
2+
package object a {
3+
val b = 10
4+
implicit class CI(s: StringContext) {
5+
def ci(args: Any*) = 10
6+
}
7+
}
8+
9+
import p.a._
10+
11+
object A:
12+
val f = b // p.a(ObjectRef(p.a)).b
13+
def foo(s: String): String = s
14+
val f1 = ci"a" // => p.a(Package(p).select(a)).CI(StringContext"a").ci()
15+
16+

tests/init-global/warn/unapplySeq-implicit-arg.check renamed to tests/init-global/warn-tasty/unapplySeq-implicit-arg.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Warning: tests/init-global/warn/unapplySeq-implicit-arg.scala:11:20 -------------------------------------------------
1+
-- Warning: tests/init-global/warn-tasty/unapplySeq-implicit-arg.scala:11:20 -------------------------------------------
22
11 | val i2: Int = Seq(i2) match // warn
33
| ^^
44
| Access uninitialized field value i2. Calling trace:

0 commit comments

Comments
 (0)