-
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
Polymorphic annotations can leak type parameters #18064
Comments
Good point. Maybe we should automatically erase all annotations in inferred types? I don't see a feasible way to ensure they are always sound and make sense. |
For the purpose of qualified types, we really want to keep the annotations Is it safe to remove the capture set for cc ? Outside of these two, it's not clear to me what purpose type annotation serve and thus I don't see what harm would be done in erasing them |
*For qualified types, as long as we are using annotations and not a "real" tree, we really want subclasses to have |
For |
I see, I think we have to do that as well, even for other reasons I'll ask on the scala discord what are the uses of type-parametrised annotations |
This is actually more general: class myAnnot[A] extends scala.annotation.Annotation
def foo[T](y: T @myAnnot[T]): T @myAnnot[T] = ???
val s: String = foo[Int](4) // Found: Int @myAnnot[T] Required: String It seems annotations are not traversed at all by the type replacer ! You'll note there was no inference in this example |
Could we always traverse annotations with every phase ? This seems like it would make them semantically clearer |
I fear this would cause a lot of problems, but don't have a concrete counter example. |
Compiler version
3.3.1-RC1 (on current main)
Minimized code
Command:
run path/to/file.scala -Xprint:typer
File:
See also example below without subtyping or inference
Output
Expectation
The text was updated successfully, but these errors were encountered: