Skip to content

Commit

Permalink
Fix expandParam's use of argForParam/isArgPrefixOf.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand authored and Kordyjan committed Jan 31, 2024
1 parent 3cac39e commit 4c531c2
Show file tree
Hide file tree
Showing 3 changed files with 24 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 @@ -5984,7 +5984,7 @@ object Types {
*/
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
16 changes: 16 additions & 0 deletions tests/pos/i19354.orig.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
}
}
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 4c531c2

Please sign in to comment.