From 572bb226faa65b9d396581f3a7ea9162067692aa Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 10 Jan 2024 15:12:16 +0000 Subject: [PATCH] Fix expandParam's use of argForParam/isArgPrefixOf. --- compiler/src/dotty/tools/dotc/core/Types.scala | 2 +- tests/pos/i19354.orig.scala | 16 ++++++++++++++++ tests/pos/i19354.scala | 7 +++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i19354.orig.scala create mode 100644 tests/pos/i19354.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 5e867e3eee97..fba5f3f56648 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -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) diff --git a/tests/pos/i19354.orig.scala b/tests/pos/i19354.orig.scala new file mode 100644 index 000000000000..0443bcb06836 --- /dev/null +++ b/tests/pos/i19354.orig.scala @@ -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 + } +} diff --git a/tests/pos/i19354.scala b/tests/pos/i19354.scala new file mode 100644 index 000000000000..db1d4961e79f --- /dev/null +++ b/tests/pos/i19354.scala @@ -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) = ""