-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Undefined reference when typing dependent annotation #21595
Comments
I tried to add a notion of "temporary parameter types", that would be used in |
@EugeneFlesselle and @natsukagami noted that we have a similar limitation with default parameters: -- [E006] Not Found Error: 21595.scala:3:32 ------------------------------------
3 | def foo(elem: Int, bla: Int = elem + 1) = bla
| ^^^^
| Not found: elem
|
| longer explanation available when compiling with `-explain` A workaround for both is to use multiple parameter lists: object Test:
def foo(elem: Int)(bla: Int = elem + 1) = bla class dummy(b: Boolean) extends annotation.StaticAnnotation
object Test:
def foo(elem: Int)(bla: Int @dummy(elem == 0)) = bla |
(Note also that I don't have this problem on my qualified types experiments, because I have a custom annotation with a custom representation and its own |
I am more and more convinced that the whole approach of letting annotations take arbitrary trees is doomed. We'll never get it to work properly in all cases. We should seriously consider switching to annotations taking types (including constant and singleton types), not trees. |
I had a similar issue with |
class dummy(b: Any) extends annotation.StaticAnnotation
class X:
def foo() = 1
def bar() = 2
def eq(x: X) = true
class Y extends X:
override def bar() = 2
override def eq(x: Y) = true
def f(x: Int) = x
def g(x: String) = x
def g(x: Int) = x
object Test:
def foo1(elem: Int, bla: Int @dummy(Array(elem))) = bla
def foo2(elem: X, bla: Int @dummy(elem.foo())) = bla // error
def foo3(elem: Y, bla: Int @dummy(elem.foo())) = bla // error
def foo4(elem: X, bla: Int @dummy(elem.bar())) = bla // error
def foo5(elem: Y, bla: Int @dummy(elem.bar())) = bla // error
def foo6(elem: X, bla: Int @dummy(elem.eq(X()))) = bla // error
def foo7(elem: Y, bla: Int @dummy(elem.eq(Y()))) = bla // error
def foo8(elem: Int, bla: Int @dummy(f(elem))) = bla
def foo9(elem: Int, bla: Int @dummy(g(elem))) = bla
def foo10(elem: Int, bla: Int @dummy(0 == elem)) = bla
def foo11(elem: Int, bla: Int @dummy(elem == 0)) = bla // error |
This issue is a duplicate of #17242. |
Originally posted by @smarter in #19957 (comment)
The text was updated successfully, but these errors were encountered: