8000 Fix #4409: Do not emit abstract methods in non-native JS classes. by sjrd · Pull Request #4425 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

Fix #4409: Do not emit abstract methods in non-native JS classes. #4425

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 2 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add a deser hack to remove abstract methods in non-native JS classes.
The deser hack is first always enabled, to test backward binary
compatibility.
  • Loading branch information
sjrd committed Feb 11, 2021
commit f8815b6cc86721b849b3b597e6387d400c86d2f7
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

package org.scalajs.ir

class InvalidIRException(val tree: Trees.Tree, message: String)
class InvalidIRException(val tree: Trees.IRNode, message: String)
extends Exception(message)
35 changes: 33 additions & 2 deletions ir/shared/src/main/scala/org/scalajs/ir/Serializers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,39 @@ object Serializers 8000 {
}
}

def readMemberDefs(owner: ClassName, ownerKind: ClassKind): List[MemberDef] =
List.fill(readInt())(readMemberDef(owner, ownerKind))
def readMemberDefs(owner: ClassName, ownerKind: ClassKind): List[MemberDef] = {
val memberDefs = List.fill(readInt())(readMemberDef(owner, ownerKind))

// #4409: Filter out abstract methods in non-native JS classes for version < 1.5
if (ownerKind.isJSClass) {
if (true) { // temp: test backward compat
memberDefs.filter { m =>
m match {
case MethodDef(_, _, _, _, _, None) => false
case _ => true
}
}
} else {
/* #4388 This check should be moved to a link-time check dependent on
* `checkIR`, but currently we only have the post-BaseLinker IR
* checker, at which points those methods have already been
* eliminated.
*/
for (m <- memberDefs) {
m match {
case MethodDef(_, _, _, _, _, None) =>
throw new InvalidIRException(m,
"Invalid abstract method in non-native JS class")
case _ =>
// ok
}
}
memberDefs
}
} else {
memberDefs
}
}

def readTopLevelExportDef(owner: ClassName,
ownerKind: ClassKind): TopLevelExportDef = {
Expand Down
0