Skip to content

Commit 4d95563

Browse files
authored
Merge pull request #2863 from gzm0/no-old-export-features
Remove old export features
2 parents b3f3694 + 4d4e4b7 commit 4d95563

File tree

14 files changed

+26
-1071
lines changed

14 files changed

+26
-1071
lines changed

compiler/src/main/scala/org/scalajs/core/compiler/GenJSCode.scala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,7 @@ abstract class GenJSCode extends plugins.PluginComponent
392392
() // fields are added via genClassFields()
393393

394394
case dd: DefDef =>
395-
if (isNamedExporterDef(dd))
396-
generatedMethods ++= genNamedExporterDef(dd)
397-
else
398-
generatedMethods ++= genMethod(dd)
395+
generatedMethods ++= genMethod(dd)
399396

400397
case _ => abort("Illegal tree in gen of genClass(): " + tree)
401398
}
@@ -798,10 +795,7 @@ abstract class GenJSCode extends plugins.PluginComponent
798795
case Template(_, _, body) => body.flatMap(gen)
799796

800797
case dd: DefDef =>
801-
if (isNamedExporterDef(dd))
802-
genNamedExporterDef(dd).toList
803-
else
804-
genMethod(dd).toList
798+
genMethod(dd).toList
805799

806800
case _ =>
807801
abort("Illegal tree in gen of genInterface(): " + tree)

compiler/src/main/scala/org/scalajs/core/compiler/GenJSExports.scala

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,7 @@ trait GenJSExports extends SubComponent { self: GenJSCode =>
7474
val exports = for {
7575
(jsName, specs) <- ctorExports.groupBy(_._1.jsName) // group by exported name
7676
} yield {
77-
val (namedExports, normalExports) = specs.partition(_._1.isNamed)
78-
79-
val normalCtors = normalExports.map(s => ExportedSymbol(s._2))
80-
val namedCtors = for {
81-
(exp, ctor) <- namedExports
82-
} yield {
83-
implicit val pos = exp.pos
84-
ExportedBody(List(JSAnyTpe),
85-
genNamedExporterBody(ctor, genFormalArg(1).ref),
86-
nme.CONSTRUCTOR.toString, pos)
87-
}
88-
89-
val ctors = normalCtors ++ namedCtors
77+
val ctors = specs.map(s => ExportedSymbol(s._2))
9078

9179
implicit val pos = ctors.head.pos
9280

@@ -106,7 +94,6 @@ trait GenJSExports extends SubComponent { self: GenJSCode =>
10694
exp <- jsInterop.registeredExportsOf(classSym)
10795
} yield {
10896
implicit val pos = exp.pos
109-
assert(!exp.isNamed, "Class cannot be exported named")
11097

11198
exp.destination match {
11299
case ExportDestination.Normal | ExportDestination.TopLevel =>
@@ -123,7 +110,6 @@ trait GenJSExports extends SubComponent { self: GenJSCode =>
123110
exp <- jsInterop.registeredExportsOf(classSym)
124111
} yield {
125112
implicit val pos = exp.pos
126-
assert(!exp.isNamed, "Module cannot be exported named")
127113

128114
exp.destination match {
129115
case ExportDestination.Normal =>
@@ -237,66 +223,6 @@ trait GenJSExports extends SubComponent { self: GenJSCode =>
237223
}
238224
}
239225

240-
/** Tests whether the given def a named exporter def that needs to be
241-
* generated with `genNamedExporterDef`.
242-
*/
243-
def isNamedExporterDef(dd: DefDef): Boolean = {
244-
jsInterop.isExport(dd.symbol) &&
245-
dd.symbol.annotations.exists(_.symbol == JSExportNamedAnnotation)
246-
}
247-
248-
/** Generate the exporter proxy for a named export */
249-
def genNamedExporterDef(dd: DefDef): Option[js.MethodDef] = {
250-
implicit val pos = dd.pos
251-
252-
if (isAbstractMethod(dd)) {
253-
None
254-
} else {
255-
val sym = dd.symbol
256-
257-
val Block(Apply(fun, _) :: Nil, _) = dd.rhs
258-
val trgSym = fun.symbol
259-
260-
val inArg =
261-
js.ParamDef(js.Ident("namedParams"), jstpe.AnyType,
262-
mutable = false, rest = false)
263-
val inArgRef = inArg.ref
264-
265-
val methodIdent = encodeMethodSym(sym)
266-
267-
Some(js.MethodDef(static = false, methodIdent,
268-
List(inArg), toIRType(sym.tpe.resultType),
269-
Some(genNamedExporterBody(trgSym, inArg.ref)))(
270-
OptimizerHints.empty, None))
271-
}
272-
}
273-
274-
private def genNamedExporterBody(trgSym: Symbol, inArg: js.Tree)(
275-
implicit pos: Position) = {
276-
277-
if (hasRepeatedParam(trgSym)) {
278-
reporter.error(pos,
279-
"You may not name-export a method with a *-parameter")
280-
}
281-
282-
val jsArgs = for {
283-
(pSym, index) <- trgSym.info.params.zipWithIndex
284-
} yield {
285-
val rhs = js.JSBracketSelect(inArg,
286-
js.StringLiteral(pSym.name.decoded))
287-
js.VarDef(js.Ident("namedArg$" + index), jstpe.AnyType,
288-
mutable = false, rhs = rhs)
289-
}
290-
291-
val jsArgRefs = jsArgs.map(_.ref)
292-
293-
// Generate JS code to prepare arguments (default getters and unboxes)
294-
val jsArgPrep = genPrepareArgs(jsArgRefs, trgSym)
295-
val jsResult = genResult(trgSym, jsArgPrep.map(_.ref), static = false)
296-
297-
js.Block(jsArgs ++ jsArgPrep :+ jsResult)
298-
}
299-
300226
private def genMemberExport(classSym: Symbol, name: TermName): js.Tree = {
301227
val alts = classSym.info.member(name).alternatives
302228

compiler/src/main/scala/org/scalajs/core/compiler/JSDefinitions.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ trait JSDefinitions { self: JSGlobalAddons =>
5858
lazy val JSBracketAccessAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSBracketAccess")
5959
lazy val JSBracketCallAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSBracketCall")
6060
lazy val JSExportAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSExport")
61-
lazy val JSExportDescendentObjectsAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSExportDescendentObjects")
62-
lazy val JSExportDescendentClassesAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSExportDescendentClasses")
6361
lazy val JSExportAllAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSExportAll")
64-
lazy val JSExportNamedAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSExportNamed")
6562
lazy val JSExportStaticAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSExportStatic")
6663
lazy val JSExportTopLevelAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSExportTopLevel")
6764
lazy val JSImportAnnotation = getRequiredClass("scala.scalajs.js.annotation.JSImport")

compiler/src/main/scala/org/scalajs/core/compiler/JSGlobalAddons.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ trait JSGlobalAddons extends JSDefinitions
6565
trait ExportInfo {
6666
val jsName: String
6767
val pos: Position
68-
val isNamed: Boolean
6968
val destination: ExportDestination
7069
}
7170

0 commit comments

Comments
 (0)