Skip to content

Commit 97b9c07

Browse files
committed
Fix #2895: Generate bridges for inline methods
There was a test before that explicitly suppressed bridge generation for inline methods. I am not sure why. @DarkDimius, does the one ring a bell?
1 parent 4ecb1f7 commit 97b9c07

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

compiler/src/dotty/tools/dotc/transform/Bridges.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class Bridges(root: ClassSymbol)(implicit ctx: Context) {
3939
* before erasure, if the following conditions are satisfied.
4040
*
4141
* - `member` and other have different signatures
42-
* - `member` is not inline
4342
* - there is not yet a bridge with the same name and signature in `root`
4443
*
4544
* The bridge has the erased info of `other` and forwards to `member`.
@@ -48,7 +47,7 @@ class Bridges(root: ClassSymbol)(implicit ctx: Context) {
4847
def bridgeExists =
4948
bridgesScope.lookupAll(member.name).exists(bridge =>
5049
bridgeTarget(bridge) == member && bridge.signature == other.signature)
51-
if (!(member.is(Inline) || member.signature == other.signature || bridgeExists))
50+
if (!(member.signature == other.signature || bridgeExists))
5251
addBridge(member, other)
5352
}
5453

tests/run/i2895.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object Foo extends (Int => Int) {
2+
inline def apply(x: Int): Int = impl(x)
3+
def impl(x: Int): Int = x + 1
4+
}
5+
6+
object Test {
7+
8+
def test(foo: Foo.type): Int = foo(41)
9+
10+
def test2(f: Int => Int): Int = f(41)
11+
12+
def main(args: Array[String]): Unit = {
13+
assert(test(Foo) == 42)
14+
assert(test2(Foo) == 42)
15+
}
16+
17+
}

0 commit comments

Comments
 (0)