Skip to content

Commit 26217ce

Browse files
authored
Merge pull request #7100 from bishabosha/issue/7090
Fix #7090: Add final flag to synthetic ImplicitFunctionN traits
2 parents b5df0a3 + 5e109c5 commit 26217ce

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ class Definitions {
129129
ClassInfo(ScalaPackageClass.thisType, cls, ObjectType :: Nil, decls)
130130
}
131131
}
132-
newClassSymbol(ScalaPackageClass, name, Trait | NoInits, completer)
132+
val flags0 = Trait | NoInits
133+
val flags = if (name.isImplicitFunction) flags0 | Final else flags0
134+
newClassSymbol(ScalaPackageClass, name, flags, completer)
133135
}
134136

135137
private def newMethod(cls: ClassSymbol, name: TermName, info: Type, flags: FlagSet = EmptyFlags): TermSymbol =

tests/neg/i2539.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ object Foo {
66
val f26: Function26[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]{ def foo(): Int } =
77
(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26) => 42 // error
88

9-
val if1: ImplicitFunction1[Int, Int]{ def foo(): Int } = implicit x1 => 42 // error
10-
119
abstract class Fun0[X] extends Function0[X]
1210
val fun0a: Fun0[Int] = () => 42
1311
val fun0b: Fun0[Int] { def foo(): Int } = () => 42 // error

tests/neg/implicit-funs.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
trait IF1 extends (given Int => Unit) // error
2+
abstract class IF2 extends (given (Int, String) => Unit) // error
3+
class IF3 extends (ImplicitFunction3[Int, String, Boolean, Unit]) { // error
4+
def apply given (Int, String, Boolean) = ()
5+
}
6+
7+
trait IFXXL extends (given ( // error
8+
Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) => Unit)
9+
10+
val IFOK: given ( // OK
11+
Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) => Unit = ()

0 commit comments

Comments
 (0)