Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from non/topic/support-type-bounds
Type bounds proof-of-concept.
- Loading branch information
Showing
4 changed files
with
62 additions
and
24 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
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,21 @@ | ||
package d_m | ||
|
||
import scala.reflect.macros.ParseException | ||
import scala.tools.nsc.Global | ||
import scala.tools.nsc.reporters.StoreReporter | ||
|
||
class StringParser[G <: Global](val global: G) { | ||
import global._ | ||
def parse(code: String): Option[Tree] = { | ||
val oldReporter = global.reporter | ||
try { | ||
val r = new StoreReporter() | ||
global.reporter = r | ||
val tree = newUnitParser(code).templateStats().headOption | ||
if (r.infos.isEmpty) tree else None | ||
} finally { | ||
global.reporter = oldReporter | ||
} | ||
} | ||
} | ||
|
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 @@ | ||
package bounds | ||
|
||
trait Leibniz[-L, +H >: L, A >: L <: H, B >: L <: H] | ||
|
||
object Test { | ||
trait Foo | ||
trait Bar extends Foo | ||
|
||
def outer[A >: Bar <: Foo] = { | ||
def test[F[_ >: Bar <: Foo]] = 999 | ||
test[λ[`b >: Bar <: Foo` => Leibniz[Bar, Foo, A, b]]] | ||
} | ||
} |