Skip to content

Commit 8be96b0

Browse files
authored
Backport "Fix expandParam's use of argForParam/isArgPrefixOf." (#19466)
Backports #19412 for 3.4.0
2 parents 20d9f65 + 9037df2 commit 8be96b0

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -6276,7 +6276,7 @@ object Types extends TypeUtils {
62766276
*/
62776277
def expandParam(tp: NamedType, pre: Type): Type =
62786278
tp.argForParam(pre) match {
6279-
case arg @ TypeRef(pre, _) if pre.isArgPrefixOf(arg.symbol) =>
6279+
case arg @ TypeRef(`pre`, _) if pre.isArgPrefixOf(arg.symbol) =>
62806280
arg.info match {
62816281
case argInfo: TypeBounds => expandBounds(argInfo)
62826282
case argInfo => useAlternate(arg)

tests/pos/i19354.orig.scala

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import javax.annotation.processing.{ AbstractProcessor, RoundEnvironment }
2+
import javax.lang.model.element.{ ElementKind, PackageElement, TypeElement }
3+
4+
import java.util as ju
5+
6+
class P extends AbstractProcessor {
7+
override def process(annotations: ju.Set[? <: TypeElement], roundEnv: RoundEnvironment): Boolean = {
8+
annotations
9+
.stream()
10+
.flatMap(annotation => roundEnv.getElementsAnnotatedWith(annotation).stream())
11+
.filter(element => element.getKind == ElementKind.PACKAGE)
12+
.map(element => element.asInstanceOf[PackageElement])
13+
true
14+
}
15+
}

tests/pos/i19354.scala

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Foo; class Bar
2+
class Test:
3+
def t1(xs: java.util.stream.Stream[? <: Foo]) =
4+
xs.map(x => take(x))
5+
6+
def take(x: Foo) = ""
7+
def take(x: Bar) = ""

0 commit comments

Comments
 (0)