Skip to content

Commit edd6653

Browse files
committed
Fix #7980: SAM type should check trait parameters
1 parent 0f0d25c commit edd6653

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4518,7 +4518,7 @@ object Types {
45184518
case et: ExprType => true
45194519
case _ => false
45204520
}
4521-
if (tp.cls.is(Trait) || zeroParams(tp.cls.primaryConstructor.info)) tp // !!! needs to be adapted once traits have parameters
4521+
if (zeroParams(tp.cls.primaryConstructor.info)) tp
45224522
else NoType
45234523
case tp: AppliedType =>
45244524
zeroParamClass(tp.superType)

tests/neg/i7980.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trait Evidence[X]
2+
3+
trait Trait[X : Evidence]
4+
def method(x : X) : X
5+
6+
given ev : Evidence[Int] = new Evidence[Int]{}
7+
val crash : Trait[Int] = (x: Int) => x // error

0 commit comments

Comments
 (0)