Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #8564: Make concrete inline methods final
- Loading branch information
1 parent
68e2023
commit 62fc9cc
Showing
6 changed files
with
66 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
object Test { | ||
|
||
abstract class A { | ||
def f1(): Int = 1 | ||
def f2(): Int | ||
inline def f3(): Int | ||
inline def f4(): Int = 1 | ||
} | ||
|
||
class B extends A { | ||
override def f1(): Int = 1 // OK | ||
override def f2(): Int = 1 // OK | ||
override def f3(): Int = 1 // error | ||
override def f4(): Int = 1 // error | ||
} | ||
|
||
class C extends A { | ||
inline override def f1(): Int = 1 // OK | ||
inline override def f2(): Int = 1 // OK retained | ||
inline override def f3(): Int = 1 // OK not retianed | ||
inline override def f4(): Int = 1 // error | ||
} | ||
|
||
abstract class D extends A { | ||
override def f1(): Int // OK | ||
override def f2(): Int // OK | ||
override def f3(): Int // error | ||
override def f4(): Int // OK not retained | ||
} | ||
|
||
abstract class E extends A { // error f1 | ||
inline override def f1(): Int | ||
inline override def f2(): Int // error | ||
inline override def f3(): Int // error | ||
inline override def f4(): Int // OK not retained | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
object Test { | ||
|
||
abstract class A { | ||
inline def f1(): String = "A.f1" | ||
inline def f2(): String = "A.f2" | ||
def f3(): String = "A.f3" | ||
} | ||
|
||
object B extends A { | ||
override inline def f1(): String = "B.f1" // error | ||
override inline def f2(): String = "B.f2" // error | ||
override inline def f3(): String = "B.f3" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
object Test { | ||
|
||
abstract class A { | ||
inline def f1(): String = "A.f1" | ||
inline def f2(): String = "A.f2" | ||
def f3(): String = "A.f3" | ||
def f(): String = "A.f" | ||
} | ||
|
||
object B extends A { | ||
override inline def f1(): String = "B.f1" | ||
override inline def f2(): String = "B.f2" | ||
override inline def f3(): String = "B.f3" | ||
override inline def f(): String = "B.f" | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
val a: A = B | ||
assert(a.f1() == "A.f1") | ||
assert(a.f2() == "A.f2") | ||
assert(a.f3() == "B.f3") | ||
assert(a.f() == "B.f") | ||
|
||
val b: B.type = B | ||
assert(b.f1() == "B.f1") | ||
assert(b.f2() == "B.f2") | ||
assert(b.f3() == "B.f3") | ||
assert(b.f() == "B.f") | ||
} | ||
|
||
} |