Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for exported methods #1501

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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
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