Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement provablyDisjoint for refined types and type aliases #15375

Merged
merged 1 commit into from
Jun 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
fullyInstantiated(tp2) && !tp1.classSymbols.exists(_.derivesFrom(tp2.symbol))
case (tp1: TypeRef, tp2: TermRef) if isEnumValue(tp2) =>
fullyInstantiated(tp1) && !tp2.classSymbols.exists(_.derivesFrom(tp1.symbol))
case (tp1: RefinedType, tp2: RefinedType) if tp1.refinedName == tp2.refinedName =>
provablyDisjoint(tp1.parent, tp2.parent) || provablyDisjoint(tp1.refinedInfo, tp2.refinedInfo)
case (tp1: TypeAlias, tp2: TypeAlias) =>
dwijnand marked this conversation as resolved.
Show resolved Hide resolved
provablyDisjoint(tp1.alias, tp2.alias)
case (tp1: Type, tp2: Type) if defn.isTupleNType(tp1) =>
provablyDisjoint(tp1.toNestedPairs, tp2)
case (tp1: Type, tp2: Type) if defn.isTupleNType(tp2) =>
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/experimental/numeric-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ trait FromDigits[T]:
def fromDigits(digits: String): T
```

Implementations of the `fromDigits` convert strings of digits to the values of the
Implementations of `fromDigits` convert strings of digits to the values of the
implementation type `T`.
The `digits` string consists of digits between `0` and `9`, possibly preceded by a
sign ("+" or "-"). Number separator characters `_` are filtered out before
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i15312.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type F[t] =
t match
case {type A = Float} => Int
case {type A = Int} => String

val a: F[{type A = Float}] = 10
val b: F[{type A = Int}] = "asd" // Found:("asd" : String) Required: F[Object{A = Int}]