Skip to content

Backport "Fix expandParam's use of argForParam/isArgPrefixOf." #19466

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

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6276,7 +6276,7 @@ object Types extends TypeUtils {
*/
def expandParam(tp: NamedType, pre: Type): Type =
tp.argForParam(pre) match {
case arg @ TypeRef(pre, _) if pre.isArgPrefixOf(arg.symbol) =>
case arg @ TypeRef(`pre`, _) if pre.isArgPrefixOf(arg.symbol) =>
arg.info match {
case argInfo: TypeBounds => expandBounds(argInfo)
case argInfo => useAlternate(arg)
Expand Down
15 changes: 15 additions & 0 deletions tests/pos/i19354.orig.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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])
true
}
}
7 changes: 7 additions & 0 deletions tests/pos/i19354.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Foo; class Bar
class Test:
def t1(xs: java.util.stream.Stream[? <: Foo]) =
xs.map(x => take(x))

def take(x: Foo) = ""
def take(x: Bar) = ""