-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Compilation test to macros project
- Remove dependence that core has on unstable macros
- Loading branch information
Showing
3 changed files
with
74 additions
and
23 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
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,51 @@ | ||
package enumeratum | ||
import scala.language.experimental.macros | ||
|
||
/** | ||
* Created by Lloyd on 1/4/17. | ||
* | ||
* Copyright 2017 | ||
*/ | ||
object FindValEnums { | ||
def apply[A] = macro ValueEnumMacros.findIntValueEntriesImpl[A] | ||
} | ||
|
||
sealed abstract class A private (val value: Int) { | ||
val text: String | ||
} | ||
|
||
object A { | ||
|
||
val values = FindValEnums[A] | ||
|
||
case object A1 extends A(1) { | ||
val text = identity("something") | ||
} | ||
|
||
def identity(str: String) = str | ||
|
||
} | ||
|
||
class C | ||
object C { | ||
def build: C = new C | ||
} | ||
|
||
sealed abstract class B private (val value: Int, val other: C) { | ||
val text: String | ||
} | ||
|
||
object B { | ||
|
||
val values = FindValEnums[B] | ||
|
||
case object B1 extends B(1, new C) { | ||
val text = identity("something") | ||
} | ||
case object B2 extends B(2, C.build) { | ||
val text = identity("something") | ||
} | ||
|
||
def identity(str: String) = str | ||
|
||
} |
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