Skip to content

Commit 66659d9

Browse files
committed
Add final flag to synthetic ImplicitFunctionN traits
1 parent cd21681 commit 66659d9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
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/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)