@@ -98,20 +98,6 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
98
98
}
99
99
}
100
100
101
- /** Whether to check that we have proper literals in some crucial places.
102
- *
103
- * This is always true in dotc. We keep the definition so that the code
104
- * code can be as similar as possible to the scalac phase.
105
- */
106
- private final val shouldCheckLiterals = true
107
-
108
- /** Whether to check and prepare exports.
109
- *
110
- * This is always true in dotc. We keep the definition so that the code
111
- * code can be as similar as possible to the scalac phase.
112
- */
113
- private final val shouldPrepareExports = true
114
-
115
101
/** DefDefs in class templates that export methods to JavaScript */
116
102
private val exporters = mutable.Map .empty[Symbol , mutable.ListBuffer [Tree ]]
117
103
@@ -155,9 +141,7 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
155
141
156
142
tree match {
157
143
case tree : TypeDef if tree.isClassDef =>
158
- if (shouldPrepareExports)
159
- registerClassOrModuleExports(sym)
160
-
144
+ registerClassOrModuleExports(sym)
161
145
if (isJSAny(sym))
162
146
transformJSClassDef(tree)
163
147
else
@@ -173,10 +157,8 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
173
157
* (Note that local-to-block can never have exports, but the error
174
158
* messages for that are handled by genExportMember).
175
159
*/
176
- if (shouldPrepareExports && (sym.is(Method ) || sym.isLocalToBlock)) {
177
- exporters.getOrElseUpdate(sym.owner, mutable.ListBuffer .empty) ++=
178
- genExportMember(sym)
179
- }
160
+ if (sym.is(Method ) || sym.isLocalToBlock)
161
+ exporters.getOrElseUpdate(sym.owner, mutable.ListBuffer .empty) ++= genExportMember(sym)
180
162
181
163
if (sym.isLocalToBlock)
182
164
super .transform(tree)
@@ -532,7 +514,6 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
532
514
} else {
533
515
// The symbol can be annotated with @js.native. Now check its JS native loading spec.
534
516
if (sym.is(Trait )) {
535
- assert(sym.is(Trait ), sym) // just tested in the previous `if`
536
517
for (annot <- sym.annotations) {
537
518
val annotSym = annot.symbol
538
519
if (isJSNativeLoadingSpecAnnot(annotSym))
@@ -604,8 +585,7 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
604
585
}
605
586
606
587
case Some (annot) if annot.symbol == jsdefn.JSGlobalAnnot =>
607
- if (shouldCheckLiterals)
608
- checkJSGlobalLiteral(annot)
588
+ checkJSGlobalLiteral(annot)
609
589
val pathName = annot.argumentConstantString(0 ).getOrElse {
610
590
if ((enclosingOwner is OwnerKind .ScalaMod ) && ! sym.owner.isPackageObject) {
611
591
report.error(
@@ -617,8 +597,7 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
617
597
checkGlobalRefPath(pathName)
618
598
619
599
case Some (annot) if annot.symbol == jsdefn.JSImportAnnot =>
620
- if (shouldCheckLiterals)
621
- checkJSImportLiteral(annot)
600
+ checkJSImportLiteral(annot)
622
601
annot.argumentConstantString(2 ).foreach { globalPathName =>
623
602
checkGlobalRefPath(globalPathName)
624
603
}
@@ -644,7 +623,6 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
644
623
else if (sym.isJSBracketCall)
645
624
report.error(" @JSBracketCall is not allowed on @js.native vals and defs" , annotPos(jsdefn.JSBracketCallAnnot ))
646
625
647
- // if (!sym.is(Accessor))
648
626
checkRHSCallsJSNative(tree, " @js.native members" )
649
627
650
628
// Check that we do not override or implement anything from a superclass
@@ -873,21 +851,18 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
873
851
874
852
for (annot <- allJSNameAnnots.headOption) {
875
853
// Check everything about the first @JSName annotation
876
- if (sym.isLocalToBlock || (enclosingOwner isnt OwnerKind .JSType )) {
854
+ if (sym.isLocalToBlock || (enclosingOwner isnt OwnerKind .JSType ))
877
855
report.error(" @JSName can only be used on members of JS types." , annot.tree)
878
- } else if (sym.is(Trait )) {
856
+ else if (sym.is(Trait ))
879
857
report.error(" @JSName cannot be used on traits." , annot.tree)
880
- } else if (isPrivateMaybeWithin(sym)) {
858
+ else if (isPrivateMaybeWithin(sym))
881
859
report.error(" @JSName cannot be used on private members." , annot.tree)
882
- } else {
883
- if (shouldCheckLiterals)
884
- checkJSNameArgument(sym, annot)
885
- }
860
+ else
861
+ checkJSNameArgument(sym, annot)
886
862
887
863
// Check that there is at most one @JSName annotation.
888
- for (duplicate <- allJSNameAnnots.tail) {
864
+ for (duplicate <- allJSNameAnnots.tail)
889
865
report.error(" Duplicate @JSName annotation." , duplicate.tree)
890
- }
891
866
}
892
867
}
893
868
@@ -924,7 +899,7 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
924
899
* module class symbol.
925
900
*/
926
901
private def markExposedIfRequired (sym : Symbol )(using Context ): Unit = {
927
- def shouldBeExposed : Boolean = {
902
+ val shouldBeExposed : Boolean = {
928
903
// it is a member of a non-native JS class
929
904
(enclosingOwner is OwnerKind .JSNonNative ) && ! sym.isLocalToBlock &&
930
905
// it is a term member, and it is not synthetic
@@ -935,7 +910,7 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
935
910
! sym.isConstructor // && !sym.isValueParameter && !sym.isParamWithDefault
936
911
}
937
912
938
- if (shouldPrepareExports && shouldBeExposed)
913
+ if (shouldBeExposed)
939
914
sym.addAnnotation(jsdefn.ExposedJSMemberAnnot )
940
915
}
941
916
}
0 commit comments