@@ -21,11 +21,9 @@ trait PrepJSExports { this: PrepJSInterop =>
21
21
22
22
import scala .reflect .internal .Flags
23
23
24
- case class ExportInfo (jsName : String , isNamed : Boolean ,
24
+ case class ExportInfo (jsName : String ,
25
25
destination : ExportDestination )(val pos : Position )
26
- extends jsInterop.ExportInfo {
27
- assert(! isNamed || destination == ExportDestination .Normal )
28
- }
26
+ extends jsInterop.ExportInfo
29
27
30
28
private final val SuppressExportDeprecationsMsg = {
31
29
" \n (you can suppress this warning in 0.6.x by passing the option " +
@@ -98,12 +96,7 @@ trait PrepJSExports { this: PrepJSInterop =>
98
96
jsInterop.registerForExport(baseSym, topLevelAndStaticExports)
99
97
100
98
// Actually generate exporter methods
101
- normalExports.flatMap { exp =>
102
- if (exp.isNamed)
103
- genNamedExport(baseSym, exp.jsName, exp.pos) :: Nil
104
- else
105
- genExportDefs(baseSym, exp.jsName, exp.pos)
106
- }
99
+ normalExports.flatMap(exp => genExportDefs(baseSym, exp.jsName, exp.pos))
107
100
}
108
101
}
109
102
@@ -147,16 +140,7 @@ trait PrepJSExports { this: PrepJSInterop =>
147
140
} else if (! isMod && ! hasAnyNonPrivateCtor) {
148
141
err(" You may not export a class that has only private constructors" )
149
142
} else {
150
- val (named, normal) = exports.partition(_.isNamed)
151
-
152
- for {
153
- exp <- named
154
- } {
155
- reporter.error(exp.pos, " You may not use @JSNamedExport on " +
156
- (if (isMod) " an object" else " a Scala.js-defined JS class" ))
157
- }
158
-
159
- jsInterop.registerForExport(sym, normal)
143
+ jsInterop.registerForExport(sym, exports)
160
144
}
161
145
}
162
146
}
@@ -204,7 +188,6 @@ trait PrepJSExports { this: PrepJSInterop =>
204
188
val allExportInfos = for {
205
189
annot <- directAnnots ++ unitAnnots
206
190
} yield {
207
- val isNamedExport = annot.symbol == JSExportNamedAnnotation
208
191
val isExportAll = annot.symbol == JSExportAllAnnotation
209
192
val isTopLevelExport = annot.symbol == JSExportTopLevelAnnotation
210
193
val isStaticExport = annot.symbol == JSExportStaticAnnotation
@@ -288,20 +271,14 @@ trait PrepJSExports { this: PrepJSInterop =>
288
271
case ExportDestination .Normal =>
289
272
// Make sure we do not override the default export of toString
290
273
def isIllegalToString = {
291
- isMember && ! isNamedExport &&
292
- name == " toString" && sym.name != nme.toString_ &&
274
+ isMember && name == " toString" && sym.name != nme.toString_ &&
293
275
sym.tpe.params.isEmpty && ! jsInterop.isJSGetter(sym)
294
276
}
295
277
if (isIllegalToString) {
296
278
reporter.error(annot.pos, " You may not export a zero-argument " +
297
279
" method named other than 'toString' under the name 'toString'" )
298
280
}
299
281
300
- if (isNamedExport && jsInterop.isJSProperty(sym)) {
301
- reporter.error(annot.pos,
302
- " You may not export a getter or a setter as a named export" )
303
- }
304
-
305
282
// Don't allow nested class / module exports without explicit name.
306
283
def isStaticNested = {
307
284
/* For Scala.js defined JS classes, sym is the class itself. For
@@ -388,7 +365,7 @@ trait PrepJSExports { this: PrepJSInterop =>
388
365
}
389
366
}
390
367
391
- ExportInfo (name, isNamedExport, destination)(annot.pos)
368
+ ExportInfo (name, destination)(annot.pos)
392
369
}
393
370
394
371
/* Filter out static exports of accessors (as they are not actually
@@ -483,7 +460,6 @@ trait PrepJSExports { this: PrepJSInterop =>
483
460
484
461
// Remove export annotations
485
462
expSym.removeAnnotation(JSExportAnnotation )
486
- expSym.removeAnnotation(JSExportNamedAnnotation )
487
463
488
464
// Add symbol to class
489
465
clsSym.info.decls.enter(expSym)
@@ -500,43 +476,6 @@ trait PrepJSExports { this: PrepJSInterop =>
500
476
exporter :: defaultGetters
501
477
}
502
478
503
- /** Generate a dummy DefDef tree for a named export. This tree is captured
504
- * by GenJSCode again to generate the required JavaScript logic.
505
- */
506
- private def genNamedExport (defSym : Symbol , jsName : String , pos : Position ) = {
507
- val clsSym = defSym.owner
508
- val scalaName = jsInterop.scalaExportName(jsName, false )
509
-
510
- // Create symbol for the new exporter method
511
- val expSym = clsSym.newMethodSymbol(scalaName, pos,
512
- Flags .SYNTHETIC | Flags .FINAL )
513
-
514
- // Mark the symbol to be a named export
515
- expSym.addAnnotation(JSExportNamedAnnotation )
516
-
517
- // Create a single parameter of type Any
518
- val param = expSym.newValueParameter(newTermName(" namedArgs" ), pos)
519
- param.setInfo(AnyTpe )
520
-
521
- // Set method type
522
- expSym.setInfo(MethodType (param :: Nil , AnyClass .tpe))
523
-
524
- // Register method to parent
525
- clsSym.info.decls.enter(expSym)
526
-
527
- // Placeholder tree
528
- def ph = Ident (Predef_??? )
529
-
530
- // Create a call to the forwarded method with ??? as args
531
- val sel : Tree = Select (This (clsSym), defSym)
532
- val call = (sel /: defSym.paramss) {
533
- (fun, params) => Apply (fun, List .fill(params.size)(ph))
534
- }
535
-
536
- // rhs is a block to prevent boxing of result
537
- typer.typedDefDef(DefDef (expSym, Block (call, ph)))
538
- }
539
-
540
479
private def genExportDefaultGetter (clsSym : Symbol , trgMethod : Symbol ,
541
480
exporter : Symbol , paramPos : Int , pos : Position ) = {
542
481
@@ -613,7 +552,6 @@ trait PrepJSExports { this: PrepJSInterop =>
613
552
/** Whether a symbol is an annotation that goes directly on a member */
614
553
private lazy val isDirectMemberAnnot = Set [Symbol ](
615
554
JSExportAnnotation ,
616
- JSExportNamedAnnotation ,
617
555
JSExportTopLevelAnnotation ,
618
556
JSExportStaticAnnotation
619
557
)
0 commit comments