Skip to content

Commit 87d59fa

Browse files
committed
Reduce restrictions on methods allowed for specialization
1 parent 4f7f3a7 commit 87d59fa

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/dotty/tools/dotc/transform/PreSpecializer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ class PreSpecializer extends MiniPhaseTransform {
8282

8383
def allowedToSpecialize(sym: Symbol): Boolean = {
8484
sym.name != nme.asInstanceOf_ &&
85-
sym.name != nme.isInstanceOf_ &&
8685
!(sym is Flags.JavaDefined) &&
87-
!sym.isConstructor
86+
!sym.isPrimaryConstructor
8887
}
8988

9089
if (allowedToSpecialize(sym)) {

src/dotty/tools/dotc/transform/TypeSpecializer.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ class TypeSpecializer extends MiniPhaseTransform with InfoTransformer {
6464
def allowedToSpecialize(sym: Symbol, numOfTypes: Int)(implicit ctx: Context) =
6565
numOfTypes > 0 &&
6666
sym.name != nme.asInstanceOf_ &&
67-
sym.name != nme.isInstanceOf_ &&
6867
!newSymbolMap.contains(sym) &&
68+
!sym.name.toString.contains("$sp") &&
6969
!(sym is Flags.JavaDefined) &&
70-
!sym.isConstructor
70+
!sym.isPrimaryConstructor
7171

7272

7373
def getSpecTypes(method: Symbol, poly: PolyType)(implicit ctx: Context): List[(Int, List[Type])] = {
@@ -189,9 +189,10 @@ class TypeSpecializer extends MiniPhaseTransform with InfoTransformer {
189189

190190
tree.tpe.widen match {
191191

192-
case poly: PolyType if !(tree.symbol.isConstructor
193-
|| (tree.symbol is Flags.Label))
194-
|| (tree.symbol.name == nme.asInstanceOf_) =>
192+
case poly: PolyType
193+
if !(tree.symbol.isPrimaryConstructor
194+
|| (tree.symbol is Flags.Label)
195+
) =>
195196
val origTParams = tree.tparams.map(_.symbol)
196197
val origVParams = tree.vparamss.flatten.map(_.symbol)
197198

0 commit comments

Comments
 (0)