Skip to content
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) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, we really need a shadowing warning for this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably. Obviously it's worst when the types match up exactly, but I've definitely shadowed things intentionally, ala port.parse.match { case Some(port) => ... }, so hard to find the right ergonomics...

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) = ""