Skip to content

Commit 2f0bc12

Browse files
committed
Fix rebase breakage
1 parent 152225d commit 2f0bc12

File tree

3 files changed

+37
-62
lines changed

3 files changed

+37
-62
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ object CaptureSet:
410410
mapRefs(newElems, tm, variance)
411411
else
412412
if variance <= 0 && !origin.isConst && (origin ne initial) then
413-
report.warning(i"trying to add elems $newElems from unrecognized source $origin of mapped set $this$whereCreated")
413+
report.warning(i"trying to add elems ${CaptureSet(newElems)} from unrecognized source $origin of mapped set $this$whereCreated")
414414
return CompareResult.fail(this)
415415
Const(newElems)
416416
super.addNewElems(added.elems, origin)
@@ -441,7 +441,7 @@ object CaptureSet:
441441
super.addNewElems(newElems, origin)
442442
.andAlso {
443443
source.tryInclude(newElems.map(bimap.backward), this)
444-
.showing(i"propagating new elems $newElems backward from $this to $source", capt)
444+
.showing(i"propagating new elems ${CaptureSet(newElems)} backward from $this to $source", capt)
445445
}
446446

447447
override def computeApprox(origin: CaptureSet)(using Context): CaptureSet =

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 34 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,67 +1884,41 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
18841884
case _ => false
18851885
}
18861886

1887-
def qualifies(m: SingleDenotation): Boolean =
1888-
// If the member is an abstract type and the prefix is a path, compare the member itself
1889-
// instead of its bounds. This case is needed situations like:
1890-
//
1891-
// class C { type T }
1892-
// val foo: C
1893-
// foo.type <: C { type T {= , <: , >:} foo.T }
1894-
//
1895-
// or like:
1896-
//
1897-
// class C[T]
1898-
// C[?] <: C[TV]
1899-
//
1900-
// where TV is a type variable. See i2397.scala for an example of the latter.
1901-
def matchAbstractTypeMember(info1: Type): Boolean = info1 match {
1902-
case TypeBounds(lo, hi) if lo ne hi =>
1903-
tp2.refinedInfo match {
1904-
case rinfo2: TypeBounds if tp1.isStable =>
1905-
val ref1 = tp1.widenExpr.select(name)
1906-
isSubType(rinfo2.lo, ref1) && isSubType(ref1, rinfo2.hi)
1907-
case _ =>
1908-
false
1909-
}
1910-
case _ => false
1911-
}
1887+
// An additional check for type member matching: If the refinement of the
1888+
// supertype `tp2` does not refer to a member symbol defined in the parent of `tp2`.
1889+
// then the symbol referred to in the subtype must have a signature that coincides
1890+
// in its parameters with the refinement's signature. The reason for the check
1891+
// is that if the refinement does not refer to a member symbol, we will have to
1892+
// resort to reflection to invoke the member. And Java reflection needs to know exact
1893+
// erased parameter types. See neg/i12211.scala. Other reflection algorithms could
1894+
// conceivably dispatch without knowning precise parameter signatures. One can signal
1895+
// this by inheriting from the `scala.reflect.SignatureCanBeImprecise` marker trait,
1896+
// in which case the signature test is elided.
1897+
def sigsOK(symInfo: Type, info2: Type) =
1898+
tp2.underlyingClassRef(refinementOK = true).member(name).exists
1899+
|| tp2.derivesFrom(defn.WithoutPreciseParameterTypesClass)
1900+
|| symInfo.isInstanceOf[MethodType]
1901+
&& symInfo.signature.consistentParams(info2.signature)
1902+
1903+
def tp1IsSingleton: Boolean = tp1.isInstanceOf[SingletonType]
1904+
1905+
// A relaxed version of isSubType, which compares method types
1906+
// under the standard arrow rule which is contravarient in the parameter types,
1907+
// but under the condition that signatures might have to match (see sigsOK)
1908+
// This relaxed version is needed to correctly compare dependent function types.
1909+
// See pos/i12211.scala.
1910+
def isSubInfo(info1: Type, info2: Type, symInfo: Type): Boolean =
1911+
info2 match
1912+
case info2: MethodType =>
1913+
info1 match
1914+
case info1: MethodType =>
1915+
val symInfo1 = symInfo.stripPoly
1916+
matchingMethodParams(info1, info2, precise = false)
1917+
&& isSubInfo(info1.resultType, info2.resultType.subst(info2, info1), symInfo1.resultType)
1918+
&& sigsOK(symInfo1, info2)
1919+
case _ => inFrozenGadtIf(tp1IsSingleton) { isSubType(info1, info2) }
1920+
case _ => inFrozenGadtIf(tp1IsSingleton) { isSubType(info1, info2) }
19121921

1913-
// An additional check for type member matching: If the refinement of the
1914-
// supertype `tp2` does not refer to a member symbol defined in the parent of `tp2`.
1915-
// then the symbol referred to in the subtype must have a signature that coincides
1916-
// in its parameters with the refinement's signature. The reason for the check
1917-
// is that if the refinement does not refer to a member symbol, we will have to
1918-
// resort to reflection to invoke the member. And Java reflection needs to know exact
1919-
// erased parameter types. See neg/i12211.scala. Other reflection algorithms could
1920-
// conceivably dispatch without knowning precise parameter signatures. One can signal
1921-
// this by inheriting from the `scala.reflect.SignatureCanBeImprecise` marker trait,
1922-
// in which case the signature test is elided.
1923-
def sigsOK(symInfo: Type, info2: Type) =
1924-
tp2.underlyingClassRef(refinementOK = true).member(name).exists
1925-
|| tp2.derivesFrom(defn.WithoutPreciseParameterTypesClass)
1926-
|| symInfo.isInstanceOf[MethodType]
1927-
&& symInfo.signature.consistentParams(info2.signature)
1928-
1929-
def tp1IsSingleton: Boolean = tp1.isInstanceOf[SingletonType]
1930-
1931-
// A relaxed version of isSubType, which compares method types
1932-
// under the standard arrow rule which is contravarient in the parameter types,
1933-
// but under the condition that signatures might have to match (see sigsOK)
1934-
// This relaxed version is needed to correctly compare dependent function types.
1935-
// See pos/i12211.scala.
1936-
def isSubInfo(info1: Type, info2: Type, symInfo: Type): Boolean =
1937-
info2 match
1938-
case info2: MethodType =>
1939-
info1 match
1940-
case info1: MethodType =>
1941-
val symInfo1 = symInfo.stripPoly
1942-
matchingMethodParams(info1, info2, precise = false)
1943-
&& isSubInfo(info1.resultType, info2.resultType.subst(info2, info1), symInfo1.resultType)
1944-
&& sigsOK(symInfo1, info2)
1945-
case _ => inFrozenGadtIf(tp1IsSingleton) { isSubType(info1, info2) }
1946-
case _ => inFrozenGadtIf(tp1IsSingleton) { isSubType(info1, info2) }
1947-
19481922
def qualifies(m: SingleDenotation): Boolean =
19491923
val info1 = m.info.widenExpr
19501924
isSubInfo(info1, tp2.refinedInfo.widenExpr, m.symbol.info.orElse(info1))

tests/neg/i2887b.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
| Recursion limit exceeded.
55
| Maybe there is an illegal cyclic reference?
66
| If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
7+
| For the unprocessed stack trace, compile with -Yno-decode-stacktraces.
78
| A recurring operation is (inner to outer):
89
|
910
| try to instantiate Z[Z]

0 commit comments

Comments
 (0)