-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Retain parameter annotations in the generation of mixin phase forwarding methods -- PR choice 2 #24893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retain parameter annotations in the generation of mixin phase forwarding methods -- PR choice 2 #24893
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| class Blah extends scala.annotation.StaticAnnotation | ||
|
|
||
| trait Barly { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will definitely use |
||
| def bar[T](a: String, @Foo v: Int)(@Foo b: T, @Blah w: Int) = () | ||
| } | ||
|
|
||
| class Bar extends Barly{ | ||
| def bar2(@Foo v: Int) = () | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import java.lang.annotation.*; | ||
|
|
||
| @Retention(RetentionPolicy.RUNTIME) | ||
| public @interface Foo { | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It needs to skip scalajs because of java reflection. My version will also fail!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good. I didnt understand the issue with scala-js testing. |
||
| //Test java runtime reflection access to @Runtime annotations on method parameters. | ||
| object Test extends App: | ||
| val method: java.lang.reflect.Method = classOf[Bar].getMethod("bar", classOf[String], classOf[Int], classOf[Object], classOf[Int]) | ||
| val annots: Array[Array[java.lang.annotation.Annotation]] = method.getParameterAnnotations() | ||
| assert(annots.length == 4) | ||
| assert(annots(0).length == 0) | ||
| assert(annots(1).length == 1) | ||
| assert(annots(1)(0).isInstanceOf[Foo]) | ||
| assert(annots(2).length == 1) | ||
| assert(annots(2)(0).isInstanceOf[Foo]) | ||
| assert(annots(3).length == 0) | ||
|
|
||
| val method2: java.lang.reflect.Method = classOf[Bar].getMethod("bar2", classOf[Int]) | ||
| val annots2: Array[Array[java.lang.annotation.Annotation]] = method2.getParameterAnnotations() | ||
| assert(annots2.length == 1) | ||
| assert(annots2(0)(0).isInstanceOf[Foo]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was over my head, but it felt like a lot of work.
I pushed a slightly different PR. If that flies, I'll add you as co-author.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the PR you mention and I like it. I was not able to clone this repo to try out the test but I assume the test still passes. No problem and appreciate the co-author. I figured my PR here was just a starting point and I have some learning to do if I were to become a further contributor. Thanks.
Update -- I took a patch of it and have tried the patch in my repo successfully.