-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9615 from lrytz/t12380
Two fixes for mixing in Java interfaces that refine a member's type
- Loading branch information
Showing
11 changed files
with
79 additions
and
5 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,8 @@ | ||
Test.scala:1: error: incompatible type in overriding | ||
def m(): String (defined in trait I) | ||
with def m(): Object (defined in class C); | ||
found : (): Object | ||
required: (): String | ||
object Test extends p.J.C with p.J.I { | ||
^ | ||
1 error |
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,14 @@ | ||
package p; | ||
|
||
public class J { | ||
public static class C { | ||
public Object m() { return new Object(); } | ||
} | ||
public interface I { | ||
public String m(); | ||
} | ||
|
||
public static class Test extends C implements I { | ||
@Override public String m() { return ""; } | ||
} | ||
} |
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,5 @@ | ||
object Test extends p.J.C with p.J.I { | ||
def main(args: Array[String]): Unit = { | ||
println((this: p.J.I).m.trim) | ||
} | ||
} |
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 @@ | ||
package p; | ||
|
||
public class A { | ||
public static class R { } | ||
|
||
/* package-protected */ R foo() { return null; } | ||
} |
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 @@ | ||
package q; | ||
|
||
public class B extends p.A { | ||
public static class RR extends p.A.R { } | ||
|
||
/* package-protected */ RR foo() { return null; } | ||
} |
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 @@ | ||
class Test extends q.B |
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,28 @@ | ||
// filter: unchecked | ||
|
||
package p; | ||
|
||
public class A { | ||
public static interface I { | ||
public I w(); | ||
} | ||
|
||
public static interface J<R extends J<R>> extends I { | ||
@Override public R w(); | ||
} | ||
|
||
public static interface K extends I { | ||
@Override public K w(); | ||
|
||
public default String mK() { return "K"; } | ||
} | ||
|
||
/* package-private */ static class B<R extends J<R>> implements J<R> { | ||
@Override public R w() { return (R) this; } | ||
} | ||
|
||
public static class C<R extends J<R>> extends B<R> implements J<R> { } | ||
|
||
// OK in Java, also OK in Scala | ||
public static class Test extends C<Test> implements K { } | ||
} |
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 @@ | ||
class Test extends p.A.C[Test] with p.A.K | ||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
assert((new Test).w.mK == "K") | ||
assert((new p.A.Test).w.mK == "K") | ||
} | ||
} |