Skip to content

Commit bdb425c

Browse files
committed
Relax matching requirement in unApply
We now always widen selector type to the superclass if necessary, no matter whether the selector type refers to a trait or a proper class.
1 parent e1dc0b4 commit bdb425c

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,14 +775,13 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
775775
* The generalizations of a type T are the smallest set G such that
776776
*
777777
* - T is in G
778-
* - If a typeref R in G represents a trait, R's superclass is in G.
778+
* - If a typeref R in G represents a class or trait, R's superclass is in G.
779779
* - If a type proxy P is not a reference to a class, P's supertype is in G
780780
*/
781781
def isSubTypeOfParent(subtp: Type, tp: Type)(implicit ctx: Context): Boolean =
782782
if (subtp <:< tp) true
783783
else tp match {
784-
case tp: TypeRef if tp.symbol.isClass =>
785-
tp.symbol.is(Trait) && isSubTypeOfParent(subtp, tp.firstParent)
784+
case tp: TypeRef if tp.symbol.isClass => isSubTypeOfParent(subtp, tp.firstParent)
786785
case tp: TypeProxy => isSubTypeOfParent(subtp, tp.superType)
787786
case _ => false
788787
}
File renamed without changes.

0 commit comments

Comments
 (0)