@@ -1884,67 +1884,41 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1884
1884
case _ => false
1885
1885
}
1886
1886
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) }
1912
1921
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
-
1948
1922
def qualifies (m : SingleDenotation ): Boolean =
1949
1923
val info1 = m.info.widenExpr
1950
1924
isSubInfo(info1, tp2.refinedInfo.widenExpr, m.symbol.info.orElse(info1))
0 commit comments