diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-04 13:57:01 -0700 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-04 13:57:01 -0700 |
commit | bc6eb79f74a30aef2eb874eb7ba3c443c49e7554 (patch) | |
tree | 8302e85440240d13006694dcdace9b77a4ee0778 /core/src/test/scala | |
parent | c103d7b024c3b0edce800c0dbd4cfaffd1aabfba (diff) | |
download | mill-bc6eb79f74a30aef2eb874eb7ba3c443c49e7554.tar.gz mill-bc6eb79f74a30aef2eb874eb7ba3c443c49e7554.tar.bz2 mill-bc6eb79f74a30aef2eb874eb7ba3c443c49e7554.zip |
Add some basic compile-time checks to enforce usage of `T{...}` within traits
Diffstat (limited to 'core/src/test/scala')
-rw-r--r-- | core/src/test/scala/forge/CacherTests.scala | 10 | ||||
-rw-r--r-- | core/src/test/scala/forge/TestGraphs.scala | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/core/src/test/scala/forge/CacherTests.scala b/core/src/test/scala/forge/CacherTests.scala index 4c346e5e..c6157a4a 100644 --- a/core/src/test/scala/forge/CacherTests.scala +++ b/core/src/test/scala/forge/CacherTests.scala @@ -46,5 +46,15 @@ object CacherTests extends TestSuite{ eval(Terminal, Terminal.value) == 7, eval(Terminal, Terminal.overriden) == 1 ) + 'errors{ + val expectedMsg = + "T{} can only be used directly within a zero-arg method defined in a class body" + + val err1 = compileError("object Foo extends Target.Cacher{ val x = T{1} }") + assert(err1.msg == expectedMsg) + + val err2 = compileError("object Foo extends Target.Cacher{ def x = {def y = T{1}} }") + assert(err2.msg == expectedMsg) + } } } diff --git a/core/src/test/scala/forge/TestGraphs.scala b/core/src/test/scala/forge/TestGraphs.scala index 5960ed4c..0d6040eb 100644 --- a/core/src/test/scala/forge/TestGraphs.scala +++ b/core/src/test/scala/forge/TestGraphs.scala @@ -100,3 +100,4 @@ class TestGraphs(){ val j = test(test(i), test(i, f), test(f)) } } + |