@@ -2,7 +2,7 @@ package dotty.tools
2
2
package dotc
3
3
package core
4
4
5
- import Types ._ , Contexts ._ , Symbols ._ , Flags ._ , Names ._ , NameOps ._ , Denotations ._
5
+ import Types ._ , Contexts ._ , Symbols ._ , Flags ._ , Names ._ , NameOps ._ , Denotations ._ , SymDenotations . *
6
6
import Decorators ._
7
7
import Phases .{gettersPhase , elimByNamePhase }
8
8
import StdNames .nme
@@ -1888,7 +1888,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1888
1888
* rebase both itself and the member info of `tp` on a freshly created skolem type.
1889
1889
*/
1890
1890
def hasMatchingMember (name : Name , tp1 : Type , tp2 : RefinedType ): Boolean =
1891
- trace(i " hasMatchingMember( $tp1 . $name :? ${tp2.refinedInfo}), mbr: ${tp1.member(name).info}" , subtyping) {
1891
+ val mbr = tp1.member(name)
1892
+ trace(i " hasMatchingMember( $tp1 . $name :? ${tp2.refinedInfo}), mbr: ${mbr.info}" , subtyping) {
1892
1893
1893
1894
// If the member is an abstract type and the prefix is a path, compare the member itself
1894
1895
// instead of its bounds. This case is needed situations like:
@@ -1931,7 +1932,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1931
1932
|| symInfo.isInstanceOf [MethodType ]
1932
1933
&& symInfo.signature.consistentParams(info2.signature)
1933
1934
1934
- def tp1IsSingleton : Boolean = tp1.isInstanceOf [SingletonType ]
1935
+ def allowGadt = mbr match
1936
+ case _ if tp1.isInstanceOf [SingletonType ] => false
1937
+ case d : UniqueRefDenotation if d.prefix == NoPrefix && d.symbol != NoSymbol => false
1938
+ case _ => true
1935
1939
1936
1940
// A relaxed version of isSubType, which compares method types
1937
1941
// under the standard arrow rule which is contravarient in the parameter types,
@@ -1947,15 +1951,15 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1947
1951
matchingMethodParams(info1, info2, precise = false )
1948
1952
&& isSubInfo(info1.resultType, info2.resultType.subst(info2, info1), symInfo1.resultType)
1949
1953
&& sigsOK(symInfo1, info2)
1950
- case _ => inFrozenGadtIf(tp1IsSingleton ) { isSubType(info1, info2) }
1951
- case _ => inFrozenGadtIf(tp1IsSingleton ) { isSubType(info1, info2) }
1954
+ case _ => inFrozenGadtIf(! allowGadt ) { isSubType(info1, info2) }
1955
+ case _ => inFrozenGadtIf(! allowGadt ) { isSubType(info1, info2) }
1952
1956
1953
1957
def qualifies (m : SingleDenotation ): Boolean =
1954
1958
val info1 = m.info.widenExpr
1955
1959
isSubInfo(info1, tp2.refinedInfo.widenExpr, m.symbol.info.orElse(info1))
1956
1960
|| matchAbstractTypeMember(m.info)
1957
1961
1958
- tp1.member(name) match // inlined hasAltWith for performance
1962
+ mbr match // inlined hasAltWith for performance
1959
1963
case mbr : SingleDenotation => qualifies(mbr)
1960
1964
case mbr => mbr hasAltWith qualifies
1961
1965
}
0 commit comments