Skip to content

Commit

Permalink
Fixing global-init WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Nov 8, 2023
1 parent 17b6e5a commit c018549
Show file tree
Hide file tree
Showing 250 changed files with 283 additions and 242 deletions.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/context-sensitivity.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ object A:
val box1: Box = new Box(new C(5))
val box2: Box = new Box(new D(10))
val m: Int = box1.value.foo()

// nopos-error: No warnings can be incurred under -Werror.
20 changes: 0 additions & 20 deletions tests/init-global/neg/global-cycle1.check
Original file line number Diff line number Diff line change
@@ -1,20 +0,0 @@
-- Error: tests/init-global/neg/global-cycle1.scala:1:7 ----------------------------------------------------------------
1 |object A { // error
| ^
| Cyclic initialization: object A -> object B -> object A. Calling trace:
| -> object A { // error [ global-cycle1.scala:1 ]
| ^
| -> val a: Int = B.b [ global-cycle1.scala:2 ]
| ^
| -> object B { [ global-cycle1.scala:5 ]
| ^
| -> val b: Int = A.a // error [ global-cycle1.scala:6 ]
| ^
-- Error: tests/init-global/neg/global-cycle1.scala:6:17 ---------------------------------------------------------------
6 | val b: Int = A.a // error
| ^^^
| Access uninitialized field value a. Call trace:
| -> object B { [ global-cycle1.scala:5 ]
| ^
| -> val b: Int = A.a // error [ global-cycle1.scala:6 ]
| ^^^
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-cycle1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ object B {

@main
def Test = print(A.a)

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-cycle14.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ object A { // error
object B {
val m: Int = A.n // error
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-cycle2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ object A {
object B {
def foo(): Int = A.a * 2 // error
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-cycle3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ class A(x: Int) {
object B {
val a: Int = A(4).foo()
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-cycle4.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ class D(x: Int) {
object O {
val a: Int = D(5).bar().foo()
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/global-cycle5.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ object C {

def main = {
A.a = new Y(); C
}
}
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/global-cycle6.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ object O {
val a = new A.Inner
val m: Int = 10
}
}
}
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-cycle7.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ object JavaTokens extends TokensCommon {
final def maxToken: Int = DOUBLE
final val DOUBLE = 188
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-cycle8.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ object P {
object Q {
def bar(b: B) = b.a.foo()
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/global-irrelevance1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ object A:
var x = 6

object B:
var y = A.x * 2 // error
var y = A.x * 2 // error
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-irrelevance2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ class B(b: Int):

object B:
new B(10)

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-irrelevance3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ object A:

object B:
var y = A.p.g()

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-irrelevance4.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ object A:

object B:
A.p.f(10)

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-irrelevance5.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ object A:

object B:
var y = A.array(0) * 2 // error

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-irrelevance6.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ object A:

object B:
var y = A.array(0).foo() * 2 // error

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-irrelevance7.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ object A:

object B:
var y = A.array(0).foo() * 2 // error

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/global-list.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ object O: // error
val c = Foo("Cherry")

object Foo:
val all: List[Foo] = List(O.a, O.b, O.c) // error // error // error
val all: List[Foo] = List(O.a, O.b, O.c) // error // error // error
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-local-var.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ class A(x: Int) {
object B {
val a: Int = A(4).foo()
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/global-region1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ object A:
val box1: Box = new Box(new C(5))
val box2: Box = new Box(new D(10))
val m: Int = box1.value.foo()

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/i11262.scala
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
object A { val x: String = B.y } // error
object B { val y: String = A.x } // error

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/i12544b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ object Enum:
def f(e: Enum): Enum = e

@main def main(): Unit = println(Enum.b)

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/i9176.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ object Test {
println(B.opposite)
}
}

// nopos-error: No warnings can be incurred under -Werror.
13 changes: 0 additions & 13 deletions tests/init-global/neg/line-spacing.check
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
-- Error: tests/init-global/neg/line-spacing.scala:4:7 -----------------------------------------------------------------
3 | B
4 | .s.length // error
| ^
| Access uninitialized field value s. Call trace:
| -> object B { [ line-spacing.scala:7 ]
| ^
| -> val s: String = s"${A.a}a" [ line-spacing.scala:8 ]
| ^^^
| -> def a: Int = [ line-spacing.scala:2 ]
| ^
| -> .s.length // error [ line-spacing.scala:4 ]
| ^
2 changes: 2 additions & 0 deletions tests/init-global/neg/line-spacing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ object A {
object B {
val s: String = s"${A.a}a"
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/mutable-array.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ object B:
val boxes: Array[A.Box] = Array(A.box)
val box: A.Box = boxes(0)
val x: Int = box.value // error

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/mutable-read1.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ object B:
val boxB: Box = new Box(5)
val boxA: Box = A.box
val m: Int = boxB.value
val n: Int = boxA.value // error
val n: Int = boxA.value // error
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/mutable-read2.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ object A:
object B:
val box: A.Box = A.box
val a: Int = box.initial
val b: Int = box.value // error
val b: Int = box.value // error
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/mutable-read3.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ object B:
val boxes: Array[A.Box] = new Array(1)
boxes(0) = A.box
val box: A.Box = boxes(0)
val x: Int = box.value // error
val x: Int = box.value // error
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/mutable-read4.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ object B:
val boxB: Box = new Box(5)
val boxA: Box = A.box
val m: Int = boxB.value
val n: Int = boxA.value // error
val n: Int = boxA.value // error
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/mutable-read5.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ object Names:
object StdNames:
val AnyRef: Names.Name = Names.name("AnyRef")
val Array: Names.Name = Names.name("Array")
val List: Names.Name = Names.name("List")
val List: Names.Name = Names.name("List")
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/mutable-read6.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ object Contexts:
object Implicits:
import Contexts.*
case class SearchFailure(tag: Int, source: SourceFile)
val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source)
val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source)
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/mutable-read7.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ abstract class Positioned:

object Trees:
class Tree extends Positioned
val emptyTree = new Tree
val emptyTree = new Tree
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/mutable-read8.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ class UncachedGroundType {

class LazyType extends UncachedGroundType

object NoCompleter extends LazyType
object NoCompleter extends LazyType
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/partial-ordering.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ object Names: // error
class MethodName(encoded: String)
object MethodName:
val ctor: MethodName = new MethodName(Names.ctorString)
def apply(name: String): MethodName = new MethodName(name)
def apply(name: String): MethodName = new MethodName(name)
// nopos-error: No warnings can be incurred under -Werror.
11 changes: 0 additions & 11 deletions tests/init-global/neg/patmat-unapplySeq.check
Original file line number Diff line number Diff line change
@@ -1,11 +0,0 @@
-- Error: tests/init-global/neg/patmat-unapplySeq.scala:8:32 -----------------------------------------------------------
8 | def apply(i: Int): Box = array(i) // error
| ^^^^^^^^
|Reading mutable state of object A during initialization of object B.
|Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace:
|-> object B: [ patmat-unapplySeq.scala:15 ]
| ^
|-> case A(b) => [ patmat-unapplySeq.scala:17 ]
| ^^^^
|-> def apply(i: Int): Box = array(i) // error [ patmat-unapplySeq.scala:8 ]
| ^^^^^^^^
2 changes: 2 additions & 0 deletions tests/init-global/neg/patmat-unapplySeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ object A:
object B:
A.array match
case A(b) =>

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/patmat-unapplySeq2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ object A:
object B:
A.array match
case A(b*) =>

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/patmat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ object C:
(Box(foo): Box[() => Int] | Holder[Int]) match
case Box(f) => f()
case Holder(x) => x

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/return.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ object A:
object B:
val n = A.foo(-10)(20)


// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/return2.scala
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ object A:

object B:
val n = A.foo(-10)(20)

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/t5366.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ object Test {
ObjA
println(IdAndMsg.values)
}
}
}
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/t9115.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ object D { // error
println(D1)
println(D2)
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/t9261.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
sealed abstract class OrderType(val reverse: OrderType)
case object Buy extends OrderType(Sell) // error
case object Sell extends OrderType(Buy)

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/t9312.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ object DeadLockTest {
final val children = Set(Child1, Child2)
}
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/t9360.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ object ObjectInit {
Obj.print
}
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
3 changes: 2 additions & 1 deletion tests/init-global/neg/unapply-implicit-arg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ object Bar {
val i2: Int = i2 match // error
case Bar(i) => i
case _ => 0
}
}
// nopos-error: No warnings can be incurred under -Werror.
Empty file.
2 changes: 2 additions & 0 deletions tests/init-global/neg/unapply-implicit-arg2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ object Bar {
case Bar(i) => i
case _ => 0
}

// nopos-error: No warnings can be incurred under -Werror.
Empty file.
Loading

0 comments on commit c018549

Please sign in to comment.