Skip to content

Commit

Permalink
Backport "Fix expandParam's use of argForParam/isArgPrefixOf." (#19466)
Browse files Browse the repository at this point in the history
Backports #19412 for 3.4.0
  • Loading branch information
Kordyjan authored Jan 19, 2024
2 parents 20d9f65 + 9037df2 commit 8be96b0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
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) = ""

0 comments on commit 8be96b0

Please sign in to comment.