8000 Fix #1795: Essentials of Scala.js-defined JS classes. by sjrd · Pull Request #1809 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

Fix #1795: Essentials of Scala.js-defined JS classes. #1809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 24, 2015
Prev Previous commit
Allow abstract members in native JS classes and traits.
With Scala.js-defined JS classes, it makes sense to have
abstract members in native JS classes and traits, to force
a Scala.js-defined JS class extending them to implement
those members.
  • Loading branch information
sjrd committed Aug 22, 2015
commit 29314b607340bae4ec3998ea1d5d88a45e5926ab
Original file line number Diff line number Diff line change
10000 Expand Up @@ -582,15 +582,16 @@ abstract class PrepJSInterop extends plugins.PluginComponent
}

if (sym.isPrimaryConstructor || sym.isValueParameter ||
sym.isParamWithDefault || sym.isAccessor && !sym.isDeferred ||
sym.isParamAccessor || sym.isSynthetic ||
sym.isParamWithDefault || sym.isAccessor ||
sym.isParamAccessor || sym.isDeferred || sym.isSynthetic ||
AllJSFunctionClasses.contains(sym.owner) ||
(enclosingOwner is OwnerKind.JSClass)) {
/* Ignore (i.e. allow) primary ctor, parameters, default parameter
* getters, accessors, param accessors, synthetic methods (to avoid
* double errors with case classes, e.g. generated copy method),
* js.Functions and js.ThisFunctions (they need abstract methods for
* SAM treatment), and any member of a Scala.js-defined class.
* getters, accessors, param accessors, abstract members, synthetic
* methods (to avoid double errors with case classes, e.g. generated
* copy method), js.Functions and js.ThisFunctions (they need abstract
* methods for SAM treatment), and any member of a Scala.js-defined
* JS class/trait.
*/
} else if (jsPrimitives.isJavaScriptPrimitive(sym)) {
// Force rhs of a primitive to be `sys.error("stub")` except for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,24 @@ class JSInteropTest extends DirectTest with TestHelpers {
| ^
"""

}

@Test
def noWarnJSAnyDeferred: Unit = {

"""
trait A extends js.Object {
abstract class A extends js.Object {
def value: Int
val x: Int
}
""" hasWarns
"""
|newSource1.scala:4: warning: Members of traits, classes and objects extending js.Any may only contain members that call js.native. This will be enforced in 1.0.
| def value: Int
| ^
|newSource1.scala:5: warning: Members of traits, classes and objects extending js.Any may only contain members that call js.native. This will be enforced in 1.0.
| val x: Int
| ^
""".hasNoWarns

"""
trait A extends js.Object {
def value: Int
val x: Int
}
""".hasNoWarns

}

Expand Down
13 changes: 13 additions & 0 deletions test-suite/src/test/resources/ScalaJSDefinedTestNatives.js