Skip to content

Commit 21f6711

Browse files
committed
Merge pull request #908 from dotty-staging/fix-#903
Parentheses around a wildcard should not produce a lambda
2 parents 08e8802 + 2bcc0b0 commit 21f6711

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ object Parsers {
322322
case Ident(name1) => placeholderParams.nonEmpty && name1 == placeholderParams.head.name
323323
case Typed(t1, _) => isWildcard(t1)
324324
case Annotated(t1, _) => isWildcard(t1)
325+
case Parens(t1) => isWildcard(t1)
325326
case _ => false
326327
}
327328

tests/pos/i903.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
object Test {
2+
def contains(s: String, i: Int) = true
3+
def test1 = {
4+
val f = contains("", (_: Int))
5+
val ff = contains("", ((_: Int)))
6+
val g: Int => Boolean = contains("", (_))
7+
val gg: Int => Boolean = contains("", ((_)))
8+
f.apply(0)
9+
// sandbox/eta.scala:4: error: type mismatch:
10+
// found : Int => Int
11+
// required: Int
12+
// val f = contains("", (_: Int))
13+
// ^
14+
// sandbox/eta.scala:5: error: apply is not a member of Boolean(f)
15+
// f.apply(0)
16+
// ^
17+
}
18+
19+
def test2 = {
20+
val f = "".contains("", (_: Int)) // dotc:
21+
f.apply(0)
22+
// sandbox/eta.scala:18: error: apply is not a member of Boolean(f)
23+
// f.apply(0)
24+
// ^
25+
}
26+
}

0 commit comments

Comments
 (0)