Skip to content

Fix assertion when trying to inline virtual (super) calls #1346

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
Jun 18, 2020
Merged

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Jun 17, 2020

Fixes #1342, but does not try to reason about when we can inline nonetheless (can we safely inline any super.xy() call?). Now emits a warning instead of crashing.

  • I've read the contributing guidelines

@dcodeIO
Copy link
Member Author

dcodeIO commented Jun 17, 2020

On a first glimpse, a better fix that allows us to inline would have to take something like this into account:

abstract class Foo {
  a(): i32 { return 1; }
  abstract b(): i32;
}
class Bar extends Foo {
  a(): i32 { return super.b(); } // TS2513
  b(): i32 { return 2; }
}

@MaxGraey
Copy link
Member

It will be great add simple test for preventing regression in future (after refactoring for example)

@dcodeIO
Copy link
Member Author

dcodeIO commented Jun 17, 2020

Last commit now inlines the super.xy() call, even though Foo#xy() cannot be inlined when called normally. Seems that this is possible, even though quite the edge case. Or does anyone see a scenario where that'd be invalid?

@MaxGraey
Copy link
Member

nice!

@dcodeIO dcodeIO merged commit 47a2af0 into master Jun 18, 2020
@github-actions
Copy link

🎉 This PR is included in version 0.12.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dcodeIO dcodeIO deleted the issue-1342 branch July 16, 2020 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler fail when overloaded method has inline decorator
2 participants