Skip to content

Commit 92dce69

Browse files
committed
Merge pull request scala#4260 from retronym/ticket/9093
SI-9093 Fix value discarding / multiple param list crasher
2 parents b605838 + c30ed29 commit 92dce69

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
11771177
}
11781178

11791179
def instantiatePossiblyExpectingUnit(tree: Tree, mode: Mode, pt: Type): Tree = {
1180-
if (mode.typingExprNotFun && pt.typeSymbol == UnitClass)
1180+
if (mode.typingExprNotFun && pt.typeSymbol == UnitClass && !tree.tpe.isInstanceOf[MethodType])
11811181
instantiateExpectingUnit(tree, mode)
11821182
else
11831183
instantiate(tree, mode, pt)

test/files/neg/t9093.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
t9093.scala:3: error: polymorphic expression cannot be instantiated to expected type;
2+
found : [C](f: C)Null
3+
required: Unit
4+
val x: Unit = apply2(0)/*(0)*/
5+
^
6+
one error found

test/files/neg/t9093.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Main {
2+
def apply2[C](fa: Any)(f: C) = null
3+
val x: Unit = apply2(0)/*(0)*/
4+
}
5+

0 commit comments

Comments
 (0)