-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Associative, commutative, Java-friendly intersection erasure
Thanks to #11603, we can now freely decide how we erase our intersection types without compromising compatibility with Scala 2. We take advantage of this by designing a new erasedGlb algorithm which respects associativity and commutativity and can also erase Java intersections without any special case. This commit also improves the way we handle intersections in Java generic signature to produce more precise types when possible and to ensure that we never emit a type that would lead to javac emitting invalid bytecode (which can happen with Scala 2: scala/bug#12300). Fixes #5139.
- Loading branch information
Showing
12 changed files
with
239 additions
and
59 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
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 A | ||
trait B | ||
|
||
class Overload { | ||
def m(ab: A&B) = ab | ||
def m(ab: B&A) = ab // error: double definition | ||
} |
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 @@ | ||
trait A { def foo(a: A) : Unit } | ||
|
||
trait C extends A { | ||
override def foo(a: A with Any): Unit // error: method foo has a different signature than the overridden declaration | ||
} |
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,9 @@ | ||
trait A | ||
trait B | ||
|
||
class Base{ | ||
def m(ab: A&B) = ab | ||
} | ||
class Derived extends Base{ | ||
override def m(ab: B&A) = ab // unexpected error | ||
} |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
trait One | ||
trait Two | ||
|
||
class X | ||
class Y extends X | ||
|
||
trait YSub extends Y | ||
|
||
class A { | ||
def foo1[T <: Object with One](x: T): Unit = {} | ||
def foo2[T <: One with Object](x: T): Unit = {} | ||
def foo3[T <: One with Two](x: T): Unit = {} | ||
def foo4[T <: Two with One](x: T): Unit = {} | ||
def foo5[T <: X with Y](x: T): Unit = {} | ||
def foo6[T <: Y with X](x: T): Unit = {} | ||
def foo7[T <: X with YSub](x: T): Unit = {} | ||
def foo8[T <: YSub with X](x: T): Unit = {} | ||
} |
Oops, something went wrong.