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 iss 8000 ue 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

Conversation

sjrd
Copy link
Member
@sjrd sjrd commented Feb 11, 2021

@gzm0 Is this an appropriate way to fix this in 1.5? Throwing the exception would be moved to the ClassDefChecker in the future.

@sjrd sjrd requested a review from gzm0 February 11, 2021 10:09
Copy link
Contributor
@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an appropriate way to fix this in 1.5? Throwing the exception would be moved to the ClassDefChecker in the future.

Absolutely. I only have minor comments.

s.tpe.params.tail.zip(sym.tpe.params).forall {
case (sParam, symParam) =>
sParam.tpe =:= symParam.tpe
if (isNonNativeJSClass(currentClassSym)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid the nesting? (maybe by checking isAbstractMethod twice or putting it into a lazy val)?

} else {
memberDefs0
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< 8000 /div>

Do this inside readMemberDefs?

case m @ MethodDef(_, name, _, _, _, None) =>
if (!hacks.use14) {
throw new InvalidIRException(m,
"Invalid abstract method in non-native JS class")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment referencing #4388 that this should be there but currently can't?

@gzm0 gzm0 linked an issue Feb 11, 2021 that may be closed by this pull request
@sjrd sjrd force-pushed the dont-emit-abstract-members-in-js-classes branch from ba11103 to 1cb55c8 Compare February 11, 2021 13:29
@sjrd
Copy link
Member Author
sjrd commented Feb 11, 2021

Updated.

In addition to addressing the comments, I had to rearrange the way the hack is done not to cause the Scala 2.11 compiler to crash. The upside is that it is easier to see exactly what will disappear when we can move the check to a ClassDefChecker.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the 0 is still necessary. But up to you.

sjrd added 2 commits February 11, 2021 16:39
The deser hack is first always enabled, to test backward binary
compatibility.
…ses.

We condition the deser hack to reading IR with version < 1.5.0.
When that hack is not enab
8A14
led and we find an abstract method in a
non-native JS class, we immediately throw an exception, since the
IR checker would not catch it as an issue.
@sjrd sjrd force-pushed the dont-emit-abstract-members-in-js-classes branch from 1cb55c8 to 294efab Compare February 11, 2021 15:40
@sjrd sjrd merged commit ff0627a into scala-js:master Feb 11, 2021
@sjrd sjrd deleted the dont-emit-abstract-members-in-js-classes branch February 11, 2021 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler emits abstract methods for JS classes
2 participants
0