-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is because we can get away with not forcing most annotations. Keep forcing scala.annotation.internal.Child. so a problematic annotation will stay unforced unless the user uses some macro to force all annotations on all methods.
- Loading branch information
1 parent
9a1f40b
commit b208ced
Showing
21 changed files
with
289 additions
and
39 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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
TestForcedIllegalAnnotations_fail.scala:4: error: Unsupported Scala 3 match expression in an annotation of method forcedMatchInAnnot; note that complex trees are not yet supported for Annotations; found in method forcedMatchInAnnot in class tastytest.ForcedIllegalAnnotations.Match. | ||
def test1 = new ForcedIllegalAnnotations.Match() // error: Unsupported Scala 3 match expression in an annotation of method forcedMatchInAnnot | ||
^ | ||
TestForcedIllegalAnnotations_fail.scala:5: error: Unsupported Scala 3 block expression in an annotation of method forcedBlockInAnnot; note that complex trees are not yet supported for Annotations; found in method forcedBlockInAnnot in class tastytest.ForcedIllegalAnnotations.Block. | ||
def test2 = new ForcedIllegalAnnotations.Block() // error: Unsupported Scala 3 block expression in an annotation of method forcedBlockInAnnot | ||
^ | ||
TestForcedIllegalAnnotations_fail.scala:5: error: Unsupported Scala 3 match expression in an annotation of method forcedMatchInAnnot; note that complex trees are not yet supported for Annotations; found in method forcedMatchInAnnot in class tastytest.ForcedIllegalAnnotations.Match. | ||
new ForcedIllegalAnnotations.Match().forcedMatchInAnnot() // error: match expression in annotation arguments | ||
^ | ||
TestForcedIllegalAnnotations_fail.scala:8: error: Unsupported Scala 3 block expression in an annotation of method forcedBlockInAnnot; note that complex trees are not yet supported for Annotations; found in method forcedBlockInAnnot in class tastytest.ForcedIllegalAnnotations.Block. | ||
new ForcedIllegalAnnotations.Block().forcedBlockInAnnot() // error: block expression in annotation arguments. | ||
^ | ||
2 errors |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package tastytest | ||
|
||
object TestForcedIllegalAnnotations { | ||
def test1 = new ForcedIllegalAnnotations.Match() // error: Unsupported Scala 3 match expression in an annotation of method forcedMatchInAnnot | ||
def test2 = new ForcedIllegalAnnotations.Block() // error: Unsupported Scala 3 block expression in an annotation of method forcedBlockInAnnot | ||
def test1 = | ||
new ForcedIllegalAnnotations.Match().forcedMatchInAnnot() // error: match expression in annotation arguments | ||
|
||
def test2 = | ||
new ForcedIllegalAnnotations.Block().forcedBlockInAnnot() // error: block expression in annotation arguments. | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
TestSelectWithTarget_fail.scala:10: error: Unsupported Scala 3 selection of method foo with @targetName("fooString"); found in method selectFooString in object tastytest.SelectWithTarget. | ||
def test = SelectWithTarget.selectFooString | ||
^ | ||
TestSelectWithTarget_fail.scala:13: error: Unsupported Scala 3 selection of method foo with @targetName("fooString"); found in method selectFooString in object tastytest.SelectWithTarget. | ||
def test = TestSelectWithTargetPre.forceAnnots[SelectWithTarget.type, SelectWithTarget.defAnnot] | ||
^ | ||
1 error |
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,25 @@ | ||
package tastytest | ||
|
||
import scala.language.experimental.macros | ||
|
||
import scala.reflect.macros.blackbox.Context | ||
|
||
object TestSelectWithTargetPre { | ||
|
||
/** forces annotations of type `A` on methods from class `T` */ | ||
def forceAnnots[T, A]: Unit = macro Macros.forceAnnotsImpl[T, A] | ||
|
||
object Macros { | ||
def forceAnnotsImpl[T, A](c: Context)(implicit T: c.WeakTypeTag[T], A: c.WeakTypeTag[A]): c.Expr[Unit] = { | ||
import c.universe._ | ||
for { | ||
method <- weakTypeOf[T].members.filter(_.isMethod) | ||
annot <- method.annotations.find(_.tree.tpe =:= weakTypeOf[A]) | ||
} { | ||
annot.tree | ||
} | ||
c.Expr[Unit](q"()") | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,16 +1,37 @@ | ||
package tastytest | ||
|
||
object TestAnnotated { | ||
def test2 = new RootAnnotated {} | ||
def test2 = forceAnnots[RootAnnotated, rootAnnot, "new tastytest.rootAnnot(1)"] | ||
def test3 = { | ||
val o = new OuterClassAnnotated {} | ||
o.foo | ||
forceAnnots[ | ||
OuterClassAnnotated, | ||
basicAnnot[String], | ||
"new <: tastytest.basicAnnot[String](OuterClassAnnotated.this.xyz)" | ||
] | ||
} | ||
def test4 = { | ||
forceAnnots[ | ||
ParameterizedAnnotated, | ||
basicAnnot[Int], | ||
"new <: tastytest.basicAnnot[Int](tastytest#ParameterizedAnnotated.type.value)" | ||
] | ||
} | ||
def test4 = new ParameterizedAnnotated(23).foo | ||
def test5 = { | ||
val o = new OuterAnnotated {} | ||
o.foo | ||
forceAnnots[OuterAnnotated, o.innerAnnot, "new OuterAnnotated.this.innerAnnot(new Inner())"] | ||
} | ||
def test6 = { | ||
forceAnnots[ | ||
SelectInAnnotated.AmbiguousAnnotated, | ||
SelectInAnnotated.ambig.annot, | ||
"new tastytest.SelectInAnnotated.ambig.annot(tastytest.SelectInAnnotated.e.type)" | ||
] | ||
} | ||
def test7 = { | ||
forceAnnots[ | ||
SelectInAnnotatedinParent.AmbiguousAnnotated, | ||
SelectInAnnotatedinParent.ambig.annotBox, | ||
"new tastytest.SelectInAnnotatedinParent.ambig.annotBox(0.0)" | ||
] | ||
} | ||
def test6 = new SelectInAnnotated.AmbiguousAnnotated {} | ||
def test7 = new SelectInAnnotatedinParent.AmbiguousAnnotated {} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
package tastytest | ||
|
||
object TestArrayAnnot { | ||
def test = new Tagged() | ||
def test = { | ||
forceAnnots[ | ||
Tagged, | ||
SuppressWarnings, | ||
"new SuppressWarnings(Array.type.apply[String]((Array[String]{\"xyz\", \"foo\"}: String*))(reflect#ClassTag.type.apply[String](classOf[java.lang.String])))" | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
package tastytest | ||
|
||
object TestNestedAnnot { | ||
def test = new TaggedMega.Tagged() | ||
def test = { | ||
val _ = new TaggedMega.Tagged() | ||
compiletimeHasChild[TaggedMega.ForceChildren]("tastytest.TaggedMega.Nested.Nested2.Tags") | ||
forceAnnots[TaggedMega.Tagged, TaggedMega.Nested.Nested2.Tags, "new tastytest#TaggedMega.Nested.Nested2.Tags(\"xyz,foo\")"] | ||
} | ||
} |
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
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
Oops, something went wrong.