forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restrict possible targets of bridge generation in traits
- Loading branch information
1 parent
aa05a8f
commit 52a051f
Showing
7 changed files
with
83 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
interface FooJavaFromScala extends NamedScala { | ||
default FooJavaFromScala self() { | ||
return this; | ||
} | ||
NamedScala foo(NamedScala x); | ||
} | ||
|
||
interface FooJavaFromJava extends NamedJava { | ||
default FooJavaFromJava self() { | ||
return this; | ||
} | ||
NamedJava foo(NamedJava x); | ||
} | ||
|
||
class BarJavaFromJava implements FooJavaFromJava { | ||
public NamedJava foo(NamedJava x) { | ||
return x; | ||
} | ||
} | ||
|
||
class BarJavaFromScala implements FooJavaFromScala { | ||
public NamedScala foo(NamedScala x) { | ||
return x; | ||
} | ||
} |
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,7 @@ | ||
trait FooScalaFromScala extends NamedScala: | ||
def self: FooScalaFromScala = this | ||
def foo(x: NamedScala): NamedScala | ||
|
||
trait FooScalaFromJava extends NamedJava: | ||
def self: FooScalaFromJava = this | ||
def foo(x: NamedJava): NamedJava |
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,3 @@ | ||
interface NamedJava { | ||
NamedJava self(); | ||
} |
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,2 @@ | ||
trait NamedScala: | ||
def self: NamedScala |
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,18 @@ | ||
class Names(xs: List[NamedScala | NamedJava]): | ||
def mkString = xs.map{ | ||
case n: NamedScala => n.self | ||
case n: NamedJava => n.self | ||
}.mkString(",") | ||
|
||
object Names: | ||
def single[T <: NamedScala](t: T): Names = Names(List(t)) | ||
def single[T <: NamedJava](t: T): Names = Names(List(t)) | ||
|
||
|
||
@main def Test() = | ||
Names.single[FooJavaFromJava](identity).mkString | ||
Names.single[FooJavaFromScala](identity).mkString | ||
Names(List(new BarJavaFromJava())).mkString | ||
Names(List(new BarJavaFromScala())).mkString | ||
Names.single[FooScalaFromJava](identity).mkString // failing in #15402 | ||
Names.single[FooScalaFromScala](identity).mkString // failing in #15402 |
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