-
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.
Make sure the TypeRef is truly unique, even when embedded in other types, such as a TypeBounds. Since we're dealing with structural equality, `TypeBounds(lo, hi) == TypeBounds(lo', hi')` if `lo == lo'` and `hi == hi'`, if `hi = ObjectTpe` and `hi' = ObjectTpe'`, `unique`'ing (hashconsing) such a `TypeBounds` would indirectly replace `ObjectTpe` with `ObjectTpeJava` or vice versa. We can't use `eq` when trying to identify `ObjectTpeJava` in `unique` due to cycles. `isAnyTpe` returns `true` for `ObjectTpeJava`. Further fixes by Lukas: - Don't show ObjectTpeJava upper bound in TypeBounds.toString - Upper bounds of wildcards should be ObjectTpeJava - Fix wildcardExtrapolation for BoundedWildcardType with hi ObjectTpeJava Reduce `_ >: lo <: ObjectTpeJava` to `lo`. This eliminates the `BoundedWildcardType` in the expected type when type-checking the lambda (c: java.util.Collection[String]).removeIf(x => true) where boolean removeIf(Predicate<? super E> filter)
- Loading branch information
Showing
9 changed files
with
96 additions
and
25 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
S.scala:1: error: class S needs to be abstract. Missing implementation for: | ||
def g(y: Int, z: java.util.List): Int // inherited from class J | ||
(Note that java.util.List does not match java.util.List[String]. To implement this raw type, use java.util.List[_ <: Object]) | ||
(Note that java.util.List does not match java.util.List[String]. To implement this raw type, use java.util.List[_]) | ||
class S extends J { | ||
^ | ||
one error found |
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,63 @@ | ||
// scalac: -Ystop-after:refchecks -verbose -Ydebug -uniqid | ||
package java.lang | ||
|
||
/* This is a pretty random test that very indirectly tests `unique`ing of `ObjectTpeJavaRef` | ||
It's minimize from scala-js, where CI chanced on a compilation order that would first | ||
unique `TypeBounds(lo, ObjectTpe)`, and then `TypeBounds(lo, ObjectTpeJava)`, | ||
which would result in a Java reference to Object being replaced by one that is used | ||
to represent a Scala occurrence of a reference to Object, which is distinct from Any. | ||
When Java code refers to Object, it's taken as the same thing as Any, at least when | ||
it comes to =:= and `... <:< Object-in-java`. | ||
*/ | ||
import java.util.Iterator | ||
|
||
class Class[A](o: Object) | ||
|
||
class Comparable[A] { def compareTo(o: A): scala.Int = ??? } | ||
|
||
object System { | ||
def currentTimeMillis(): scala.Long = ??? | ||
|
||
def arraycopy(src: Object, srcPos: scala.Int, dest: Object, destPos: scala.Int, length: scala.Int): Unit = { | ||
import scala.{Boolean, Double} | ||
|
||
def mismatch(): Nothing = | ||
throw new ArrayStoreException("Incompatible array types") | ||
|
||
def copyPrim[@specialized T](src: Array[T], dest: Array[T]): Unit = { | ||
var i = length-1 | ||
while (i >= 0) { | ||
dest(i+destPos) = src(i+srcPos) | ||
i -= 1 | ||
} | ||
} | ||
|
||
def copyRef(src: Array[AnyRef], dest: Array[AnyRef]): Unit = { | ||
val x = (src.length, dest.length) | ||
|
||
var i = length-1 | ||
while (i >= 0) { | ||
dest(i+destPos) = src(i+srcPos) | ||
i -= 1 | ||
} | ||
} | ||
|
||
(src match { | ||
case src: Array[Boolean] => | ||
dest match { | ||
case dest: Array[Boolean] => copyPrim(src, dest) | ||
case _ => mismatch() | ||
} | ||
|
||
}) | ||
} | ||
|
||
def identityHashCode(x: Object): scala.Int = { | ||
x.getClass | ||
1 | ||
} | ||
} | ||
|
||
trait Iterable[T] { | ||
def iterator(): java.util.Iterator[T] | ||
} |
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