-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test clause interleaving and value class
- Loading branch information
1 parent
78fbf04
commit f337507
Showing
10 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Error: tests/neg/unroll-clause-interleaving.scala:6:12 -------------------------------------------------------------- | ||
6 | final def foo(@unroll x: Int = 0)[T](// error | ||
| ^ | ||
| Cannot have multiple parameter lists containing `@unroll` annotation | ||
7 | s: T, | ||
8 | @unroll y: Boolean = true, | ||
9 | ): String = "" + x + s + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//> using options -experimental | ||
|
||
import scala.annotation.unroll | ||
|
||
class Unrolled { | ||
final def foo(@unroll x: Int = 0)[T](// error | ||
s: T, | ||
@unroll y: Boolean = true, | ||
): String = "" + x + s + y | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//> using options -experimental | ||
|
||
@main def Test: Unit = | ||
val u = Unrolled() | ||
TestV1().test(u) | ||
TestV2().test(u) | ||
TestV3().test(u) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//> using options -experimental | ||
|
||
import scala.annotation.unroll | ||
|
||
class Unrolled { | ||
final def foo(x: Int)[T]( | ||
s: T, | ||
): String = "" + x + s | ||
} | ||
|
||
class TestV1 { | ||
def test(u: Unrolled): Unit = | ||
assert(u.foo(0)("foo").startsWith("0foo")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//> using options -experimental | ||
|
||
import scala.annotation.unroll | ||
|
||
class Unrolled { | ||
final def foo(x: Int)[T]( | ||
s: T, | ||
@unroll y: Boolean = true, | ||
): String = "" + x + s + y | ||
} | ||
|
||
class TestV2 { | ||
def test(u: Unrolled): Unit = | ||
assert(u.foo(0)("foo").startsWith("0footrue")) | ||
assert(u.foo(0)("foo", false).startsWith("0foofalse")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//> using options -experimental | ||
|
||
import scala.annotation.unroll | ||
|
||
class Unrolled { | ||
final def foo(x: Int)[T]( | ||
s: T, | ||
@unroll y: Boolean = true, | ||
@unroll i: Int = 0, | ||
): String = "" + x + s + y + i | ||
} | ||
|
||
class TestV3 { | ||
def test(u: Unrolled): Unit = | ||
assert(u.foo(0)("foo").startsWith("0footrue0")) | ||
assert(u.foo(0)("foo", false).startsWith("0foofalse0")) | ||
assert(u.foo(0)("foo", false, 1).startsWith("0foofalse1")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//> using options -experimental | ||
|
||
@main def Test: Unit = | ||
val u = Unrolled(0) | ||
TestV1().test(u) | ||
TestV2().test(u) | ||
TestV3().test(u) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//> using options -experimental | ||
|
||
import scala.annotation.unroll | ||
|
||
class Unrolled(val x: Int) extends AnyVal { | ||
final def foo( | ||
s: String, | ||
): String = "" + x + s | ||
} | ||
|
||
class TestV1: | ||
def test(u: Unrolled): Unit = | ||
assert(u.foo("foo").startsWith("0foo")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//> using options -experimental | ||
|
||
import scala.annotation.unroll | ||
|
||
class Unrolled(val x: Int) extends AnyVal { | ||
final def foo( | ||
s: String, | ||
@unroll y: Boolean = true, | ||
): String = "" + x + s + y | ||
} | ||
|
||
class TestV2: | ||
def test(u: Unrolled): Unit = | ||
assert(u.foo("foo").startsWith("0footrue")) | ||
assert(u.foo("foo", false).startsWith("0foofalse")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//> using options -experimental | ||
|
||
import scala.annotation.unroll | ||
|
||
class Unrolled(val x: Int) extends AnyVal { | ||
final def foo( | ||
s: String, | ||
@unroll y: Boolean = true, | ||
@unroll i: Int = 0 | ||
): String = "" + x + s + y + i | ||
} | ||
|
||
class TestV3: | ||
def test(u: Unrolled): Unit = | ||
assert(u.foo("foo").startsWith("0footrue0")) | ||
assert(u.foo("foo", false).startsWith("0foofalse0")) | ||
assert(u.foo("foo", false, 1).startsWith("0foofalse1")) |