@@ -7,9 +7,10 @@ package dotty.tools.dotc
7
7
package backend .jvm
8
8
9
9
import dotty .tools .backend .jvm .GenBCodePipeline
10
- import dotty .tools .dotc .ast .Trees .{ Select , Apply }
11
- import dotty .tools .dotc .ast .tpd
10
+ import dotty .tools .dotc .ast .Trees .Select
11
+ import dotty .tools .dotc .ast .tpd . _
12
12
import dotty .tools .dotc .core .Names .TermName
13
+ import dotty .tools .dotc .core .StdNames
13
14
import dotty .tools .dotc .core .StdNames ._
14
15
import dotty .tools .dotc .core .Types .{JavaArrayType , ErrorType , Type }
15
16
@@ -42,7 +43,6 @@ class DottyPrimitives(ctx: Context) {
42
43
43
44
/** Return the code for the given symbol. */
44
45
def getPrimitive (sym : Symbol ): Int = {
45
- assert(isPrimitive(sym), " Unknown primitive " + sym)
46
46
primitives(sym)
47
47
}
48
48
@@ -55,7 +55,7 @@ class DottyPrimitives(ctx: Context) {
55
55
* @param tpe The type of the receiver object. It is used only for array
56
56
* operations
57
57
*/
58
- def getPrimitive (app : tpd. Apply , tpe : Type )(implicit ctx : Context ): Int = {
58
+ def getPrimitive (app : Apply , tpe : Type )(implicit ctx : Context ): Int = {
59
59
val fun = app.fun.symbol
60
60
val defn = ctx.definitions
61
61
val code = app.fun match {
@@ -404,8 +404,13 @@ class DottyPrimitives(ctx: Context) {
404
404
primitives.toMap
405
405
}
406
406
407
- def isPrimitive (sym : Symbol ): Boolean = {
408
- (primitives contains sym) || sym == NoSymbol // the only trees that do not have a symbol assigned are array.{update,select,length}
407
+ def isPrimitive (fun : Tree ): Boolean = {
408
+ (primitives contains fun.symbol(ctx)) ||
409
+ (fun.symbol(ctx) == NoSymbol // the only trees that do not have a symbol assigned are array.{update,select,length,clone}}
410
+ && (fun match {
411
+ case Select (_, StdNames .nme.clone_) => false // but array.clone is NOT a primitive op.
412
+ case _ => true
413
+ }))
409
414
}
410
415
411
416
}
0 commit comments