-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
error when unrolling trait constructors
Traits are forbidden in source code from having secondary constructors, which is what the current transform would generate. Trait parameters are encoded in concrete implementing classes as getter methods, perhaps unroll could provide default implementations, but this is unexplored.
- Loading branch information
1 parent
809f12c
commit 1f98384
Showing
3 changed files
with
17 additions
and
1 deletion.
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
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,4 @@ | ||
-- Error: tests/neg/unroll-traitConstructor.scala:5:12 ----------------------------------------------------------------- | ||
5 |trait Unroll(a: String, @unroll b: Boolean = true): // error | ||
| ^ | ||
| implementation restriction: Unrolled method cannot be a trait constructor |
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,8 @@ | ||
//> using options -experimental | ||
|
||
import scala.annotation.unroll | ||
|
||
trait Unroll(a: String, @unroll b: Boolean = true): // error | ||
def show: String = a + b | ||
|
||
class Bar(arg: String, bool: Boolean) extends Unroll(arg, bool) |