Skip to content

Commit c6de910

Browse files
authored
Merge pull request #15375 from dotty-staging/fix-15312
Implement `provablyDisjoint` for refined types and type aliases
2 parents 5de1da3 + f1d378c commit c6de910

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -2654,6 +2654,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
26542654
fullyInstantiated(tp2) && !tp1.classSymbols.exists(_.derivesFrom(tp2.symbol))
26552655
case (tp1: TypeRef, tp2: TermRef) if isEnumValue(tp2) =>
26562656
fullyInstantiated(tp1) && !tp2.classSymbols.exists(_.derivesFrom(tp1.symbol))
2657+
case (tp1: RefinedType, tp2: RefinedType) if tp1.refinedName == tp2.refinedName =>
2658+
provablyDisjoint(tp1.parent, tp2.parent) || provablyDisjoint(tp1.refinedInfo, tp2.refinedInfo)
2659+
case (tp1: TypeAlias, tp2: TypeAlias) =>
2660+
provablyDisjoint(tp1.alias, tp2.alias)
26572661
case (tp1: Type, tp2: Type) if defn.isTupleNType(tp1) =>
26582662
provablyDisjoint(tp1.toNestedPairs, tp2)
26592663
case (tp1: Type, tp2: Type) if defn.isTupleNType(tp2) =>

docs/_docs/reference/experimental/numeric-literals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ trait FromDigits[T]:
7373
def fromDigits(digits: String): T
7474
```
7575

76-
Implementations of the `fromDigits` convert strings of digits to the values of the
76+
Implementations of `fromDigits` convert strings of digits to the values of the
7777
implementation type `T`.
7878
The `digits` string consists of digits between `0` and `9`, possibly preceded by a
7979
sign ("+" or "-"). Number separator characters `_` are filtered out before

tests/pos/i15312.scala

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type F[t] =
2+
t match
3+
case {type A = Float} => Int
4+
case {type A = Int} => String
5+
6+
val a: F[{type A = Float}] = 10
7+
val b: F[{type A = Int}] = "asd" // Found:("asd" : String) Required: F[Object{A = Int}]

0 commit comments

Comments
 (0)