Skip to content

Commit

Permalink
Add support for exported methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-bucev committed Feb 29, 2024
1 parent 2592006 commit d865ac1
Show file tree
Hide file tree
Showing 11 changed files with 762 additions and 6 deletions.
20 changes: 20 additions & 0 deletions frontends/benchmarks/dotty-specific/invalid/ExportedMethods1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
object ExportedMethods1 {
case class Counter(var x: BigInt) {
def add(y: BigInt): Unit = {
require(y >= 0)
x += y
}
}

case class Base(cnt: Counter) {
export cnt.*
}

case class Wrapper(base: Base) {
export base.*

def addWith(y: BigInt): Unit = {
add(y) // invalid
}
}
}
11 changes: 11 additions & 0 deletions frontends/benchmarks/dotty-specific/invalid/ExportedMethods2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object ExportedMethods2 {
import ExportedMethodsExt.SimpleCounter.*

case class Wrapper(base: Base) {
export base.*

def addWith(y: BigInt): Unit = {
add(y) // invalid
}
}
}
11 changes: 11 additions & 0 deletions frontends/benchmarks/dotty-specific/invalid/ExportedMethods3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object ExportedMethods3 {
import ExportedMethodsExt.CounterWithInvariant.*

case class Wrapper(base: Base) {
export base.*

def addWith(y: BigInt): Unit = {
x = y
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
object ExportedMethodsExt {

// This object is used for the other ExportedMethods
// but we need to have at least one invalid VC to pass the "invalid" test suite
def dummyInvalid(x: BigInt): Unit = {
assert(x == 0)
}

object SimpleCounter {
case class Counter(var x: BigInt) {
def add(y: BigInt): Unit = {
require(y >= 0)
x += y
}

def parametricAdd[T](y: BigInt, t: T): Unit = {
require(y >= 0)
x += y
}
}

case class Base(cnt: Counter) {
export cnt.*
}
}

object CounterWithInvariant {
case class Counter(var x: BigInt) {
require(x >= 0)

def add(y: BigInt): Unit = {
require(y >= 0)
x += y
}

def parametricAdd[T](y: BigInt, t: T): Unit = {
require(y >= 0)
x += y
}
}

case class Base(cnt: Counter) {
export cnt.*
}
}

object AbstractCounter {
abstract case class Counter() {
var x: BigInt

def add(y: BigInt): Unit = {
require(y >= 0)
x += y
}

def parametricAdd[T](y: BigInt, t: T): Unit = {
require(y >= 0)
x += y
}
}

case class Base(cnt: Counter) {
export cnt.*
}
}

object AbstractBaseAndCounter {
abstract case class Counter() {
var x: BigInt

def add(y: BigInt): Unit = {
require(y >= 0)
x += y
}

def parametricAdd[T](y: BigInt, t: T): Unit = {
require(y >= 0)
x += y
}
}

abstract case class Base() {
val cnt: Counter
export cnt.*
}
}
}
Loading

0 comments on commit d865ac1

Please sign in to comment.