@@ -247,11 +247,11 @@ abstract class GenJSCode extends plugins.PluginComponent
247
247
val tree = if (isRawJSType(sym.tpe)) {
248
248
assert(! isRawJSFunctionDef(sym),
249
249
s " Raw JS function def should have been recorded: $cd" )
250
- if (! sym.isInterface && isScalaJSDefinedJSClass(sym))
250
+ if (! sym.isTraitOrInterface && isScalaJSDefinedJSClass(sym))
251
251
genScalaJSDefinedJSClass(cd)
252
252
else
253
253
genRawJSClassData(cd)
254
- } else if (sym.isInterface ) {
254
+ } else if (sym.isTraitOrInterface ) {
255
255
genInterface(cd)
256
256
} else if (sym.isImplClass) {
257
257
genImplClass(cd)
@@ -288,7 +288,7 @@ abstract class GenJSCode extends plugins.PluginComponent
288
288
val sym = cd.symbol
289
289
implicit val pos = sym.pos
290
290
291
- assert(! sym.isInterface && ! sym.isImplClass,
291
+ assert(! sym.isTraitOrInterface && ! sym.isImplClass,
292
292
" genClass() must be called only for normal classes: " + sym)
293
293
assert(sym.superClass != NoSymbol , sym)
294
294
@@ -496,10 +496,10 @@ abstract class GenJSCode extends plugins.PluginComponent
496
496
497
497
val classIdent = encodeClassFullNameIdent(sym)
498
498
val superClass =
499
- if (sym.isInterface ) None
499
+ if (sym.isTraitOrInterface ) None
500
500
else Some (encodeClassFullNameIdent(sym.superClass))
501
501
val jsName =
502
- if (sym.isInterface || sym.isModuleClass) None
502
+ if (sym.isTraitOrInterface || sym.isModuleClass) None
503
503
else Some (fullJSNameOf(sym))
504
504
505
505
js.ClassDef (classIdent, ClassKind .RawJSType ,
@@ -584,7 +584,7 @@ abstract class GenJSCode extends plugins.PluginComponent
584
584
parent <- sym.info.parents
585
585
typeSym = parent.typeSymbol
586
586
_ = assert(typeSym != NoSymbol , " parent needs symbol" )
587
- if ( typeSym.isInterface)
587
+ if typeSym.isTraitOrInterface
588
588
} yield {
589
589
encodeClassFullNameIdent(typeSym)
590
590
}
@@ -1045,11 +1045,22 @@ abstract class GenJSCode extends plugins.PluginComponent
1045
1045
mutable = false , rest = false )
1046
1046
}
1047
1047
1048
+ /* When scalac uses impl classes, we cannot trust `rhs` to be
1049
+ * `EmptyTree` for deferred methods (probably due to an internal bug
1050
+ * of scalac), as can be seen in run/t6443.scala.
1051
+ * However, when it does not use impl class anymore, we have to use
1052
+ * `rhs == EmptyTree` as predicate, just like the JVM back-end does.
1053
+ */
1054
+ def isAbstractMethod =
1055
+ if (scalaUsesImplClasses) sym.isDeferred || sym.owner.isInterface
1056
+ else rhs == EmptyTree
1057
+
1048
1058
if (scalaPrimitives.isPrimitive(sym) &&
1049
1059
! jsPrimitives.shouldEmitPrimitiveBody(sym)) {
1050
1060
None
1051
- } else if (sym.isDeferred || sym.owner.isInterface) {
1052
- val body = if (sym.hasAnnotation(JavaDefaultMethodAnnotation )) {
1061
+ } else if (isAbstractMethod) {
1062
+ val body = if (scalaUsesImplClasses &&
1063
+ sym.hasAnnotation(JavaDefaultMethodAnnotation )) {
1053
1064
/* For an interface method with @JavaDefaultMethod, make it a
1054
1065
* default method calling the impl class method.
1055
1066
*/
@@ -1075,7 +1086,7 @@ abstract class GenJSCode extends plugins.PluginComponent
1075
1086
None
1076
1087
} else if (sym.isClassConstructor && isHijackedBoxedClass(sym.owner)) {
1077
1088
None
1078
- } else if (! sym.owner.isImplClass &&
1089
+ } else if (scalaUsesImplClasses && ! sym.owner.isImplClass &&
1079
1090
sym.hasAnnotation(JavaDefaultMethodAnnotation )) {
1080
1091
// Do not emit trait impl forwarders with @JavaDefaultMethod
1081
1092
None
@@ -1259,14 +1270,23 @@ abstract class GenJSCode extends plugins.PluginComponent
1259
1270
}
1260
1271
1261
1272
initialThis match {
1262
- case This (_) =>
1273
+ case Ident (_) =>
1274
+ // TODO Is this special-case really needed?
1275
+ withScopedVars(
1276
+ fakeTailJumpParamRepl := (thisDef.symbol, initialThis.symbol)
1277
+ ) {
1278
+ genInnerBody()
1279
+ }
1280
+
1281
+ case _ =>
1263
1282
val thisSym = thisDef.symbol
1264
1283
if (thisSym.isMutable)
1265
1284
mutableLocalVars += thisSym
1266
1285
1267
1286
val thisLocalIdent = encodeLocalSym(thisSym)
1287
+ val genRhs = genExpr(initialThis)
1268
1288
val thisLocalVarDef = js.VarDef (thisLocalIdent,
1269
- currentClassType, thisSym.isMutable, genThis() )
1289
+ currentClassType, thisSym.isMutable, genRhs )
1270
1290
1271
1291
val innerBody = {
1272
1292
withScopedVars(
@@ -1277,13 +1297,6 @@ abstract class
10000
GenJSCode extends plugins.PluginComponent
1277
1297
}
1278
1298
1279
1299
js.Block (thisLocalVarDef, innerBody)
1280
-
1281
- case Ident (_) =>
1282
- withScopedVars(
1283
- fakeTailJumpParamRepl := (thisDef.symbol, initialThis.symbol)
1284
- ) {
1285
- genInnerBody()
1286
- }
1287
1300
}
1288
1301
1289
1302
case _ =>
@@ -3803,7 +3816,7 @@ abstract class GenJSCode extends plugins.PluginComponent
3803
3816
/** Gen JS code representing a JS class (subclass of js.Any) */
3804
3817
private def genPrimitiveJSClass (sym : Symbol )(
3805
3818
implicit pos : Position ): js.Tree = {
3806
- assert(! isStaticModule(sym) && ! sym.isInterface ,
3819
+ assert(! isStaticModule(sym) && ! sym.isTraitOrInterface ,
3807
3820
s " genPrimitiveJSClass called with non-class $sym" )
3808
3821
js.LoadJSConstructor (jstpe.ClassType (encodeClassFullName(sym)))
3809
3822
}
0 commit comments