Skip to content
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

java stream API interop regression in 3.4.0-RC1 #19354

Closed
SimY4 opened this issue Jan 2, 2024 · 1 comment · Fixed by #19412
Closed

java stream API interop regression in 3.4.0-RC1 #19354

SimY4 opened this issue Jan 2, 2024 · 1 comment · Fixed by #19412

Comments

@SimY4
Copy link

SimY4 commented Jan 2, 2024

Compiler version

3.4.0-RC1

Minimized code

import javax.annotation.processing.{ AbstractProcessor, RoundEnvironment }
import javax.lang.model.element.{ ElementKind, PackageElement, TypeElement }

import java.util as ju

class P extends AbstractProcessor {
  override def process(annotations: ju.Set[? <: TypeElement], roundEnv: RoundEnvironment): Boolean = {
    annotations
      .stream()
      .flatMap(annotation => roundEnv.getElementsAnnotatedWith(annotation).stream())
      .filter(element => element.getKind == ElementKind.PACKAGE)
      .map(element => element.asInstanceOf[PackageElement])
      .toList()
    true
  }
}

Output

Ambiguous overload. The overloaded alternatives of method getElementsAnnotatedWith in trait RoundEnvironment with types
 (x$0: Class[? <: java.lang.annotation.Annotation]):
  java.util.Set[? <: javax.lang.model.element.Element]
 (x$0: javax.lang.model.element.TypeElement):
  java.util.Set[? <: javax.lang.model.element.Element]
both match arguments ((annotation : Nothing))

Expectation

This java interop with Stream APIs worked in 3.3.1 and all versions before. Regressed in 3.4.0-RC1

@SimY4 SimY4 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 2, 2024
@nicolasstucki nicolasstucki added compat:java and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 9, 2024
@dwijnand
Copy link
Member

Regressed with the use of asSeenFrom in #18201.

jchyb added a commit that referenced this issue Jan 11, 2024
…est (#19424)

Looks like the issue with main and the nightly release was caused by the
test in #19354. I checked and that `toList` method does not seem to
affect what is being tested there (the previous error would still appear
without it), so I removed it here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants